var allDigits = ""; function on_dtmf(digits) { if (digits == "3") { return "seek:+1000"; } if (digits == "1") { return "seek:-1000"; } if (digits == "0") { return "seek:0"; } if (digits == "6") { return "speed:+1"; } if (digits == "5") { return "speed:0"; } if (digits == "4") { return "speed:-1"; } if (digits == "2") { return "pause"; } if (digits == "#") { return allDigits; } if (digits == "*") { return "hangup"; } console_log("digit: " + digits + "\n"); allDigits += digits; } var BONG = "v=4000;>=0;+=2;#(60,0);v=2000;d(940,0)"; session.answer(); tt = new TeleTone(session); tt.addTone("d", 350.0, 440.0, 0.0); for(x = 0; x < 2; x++) { tt.generate(BONG); } function on_dtmf_speak(digits) { console_log("Digit " + digits + "\n"); if (digits == "#") { return "hangup"; } } while(session.ready()) { allDigits = ""; //test = session.streamFile("/tmp/demo.wav", "", "on_dtmf"); test = session.speak("cepstral", "david", "hello what's up blah blah the rain in spain falls mainly on the plain little boy blue go blow your horn", "on_dtmf_speak"); if (test == "hangup") { break; } console_log("INPUT: [" + test + "]\n"); }