callback.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. function all_done(s, how)
  2. freeswitch.console_log("info", "done: " .. how .. "\n");
  3. end
  4. function my_cb(s, type, obj, arg)
  5. if (arg) then
  6. freeswitch.console_log("info", "\ntype: " .. type .. "\n" .. "arg: " .. arg .. "\n");
  7. else
  8. freeswitch.console_log("info", "\ntype: " .. type .. "\n");
  9. end
  10. if (type == "dtmf") then
  11. freeswitch.console_log("info", "\ndigit: [" .. obj['digit'] .. "]\nduration: [" .. obj['duration'] .. "]\n");
  12. if (obj['digit'] == "1") then
  13. --session:speak("seek backwards");
  14. return "seek:-9000";
  15. end
  16. if (obj['digit'] == "2") then
  17. --session:speak("start over");
  18. return "seek:0";
  19. end
  20. if (obj['digit'] == "3") then
  21. --session:speak("seek forward");
  22. return "seek:+9000";
  23. end
  24. if (obj['digit'] == "4") then
  25. --session:speak("speed faster");
  26. return "speed:+1";
  27. end
  28. if (obj['digit'] == "5") then
  29. --session:speak("speed normal");
  30. return "speed:0";
  31. end
  32. if (obj['digit'] == "6") then
  33. --session:speak("speed slower");
  34. return "speed:-1";
  35. end
  36. if (obj['digit'] == "7") then
  37. --session:speak("volume up");
  38. return "volume:+1";
  39. end
  40. if (obj['digit'] == "8") then
  41. --session:speak("volume normal");
  42. return "volume:0";
  43. end
  44. if (obj['digit'] == "9") then
  45. --session:speak("volume down");
  46. return "volume:-1";
  47. end
  48. if (obj['digit'] == "*") then
  49. --session:speak("stop");
  50. return "stop";
  51. end
  52. if (obj['digit'] == "0") then
  53. --session:speak("pause");
  54. return "pause";
  55. end
  56. if (obj['digit'] == "#") then
  57. return "break";
  58. end
  59. else
  60. freeswitch.console_log("info", obj:serialize("xml"));
  61. end
  62. end
  63. blah = "args";
  64. ---session:set_tts_parms("flite", "kal");
  65. session:setHangupHook("all_done");
  66. session:setInputCallback("my_cb", "blah");
  67. session:streamFile("/ram/swimp.raw");
  68. --session:speak("Thank you, good bye!");