You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sometimes I get an error when I immediately call play on a connected call. the call is successfully connected but looks like the state is not updated before I run play, and there's no function to wait for the state. Adding a sleep helps before play.
Error connecting call: Error: Can't call play() on a call not established yet.
at /Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4254:16
at new Promise (<anonymous>)
at CallConsumer.play (/Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4252:12)
at CallConsumer.playTTS (/Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4301:17)
at EventEmitter.<anonymous> (/Users/seven/work/call-translator/js/connect-tts.js:27:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
js:
require('dotenv').config()const{ Voice }=require("@signalwire/realtime-api")require("util").inspect.defaultOptions.depth=null;constclient=newVoice.Client({project: process.env.SIGNALWIRE_PROJECT_ID,token: process.env.SIGNALWIRE_TOKEN,contexts: ["home"],});console.log("Call Handler Started");client.on("call.received",async(call)=>{console.log("Got a new call",call.id,call.from,call.to);constplan=newVoice.DeviceBuilder().add(Voice.DeviceBuilder.Sip({from: "sip:[email protected]",to: "sip:[email protected]:20003;transport=tcp",timeout: 30,}));try{console.log("Connecting to peer",plan);constpeer=awaitcall.connect(plan);console.log("B","Call connected! id =",peer.id);console.log("hello")letplayback=awaitpeer.playTTS({text: 'hello',language: 'en-US'});awaitplayback.ended();console.log("how are you")playback=awaitpeer.playTTS({text: 'how are you',language: 'en-US'});awaitplayback.ended();console.log("wait for end")if(peer.active){awaitpeer.waitFor('ended')console.log("call ended")}if(peer.active){console.log("hangup peer");awaitpeer.hangup();}}catch(error){console.error("Error connecting call:",error);}console.log("waiting b leg to end");awaitcall.disconnected()console.log("waiting a leg to end");awaitcall.waitFor('ended')console.log("done");});console.log("ready");
Got a new call e5a25328-2548-432e-b70d-8a612318372c sip:[email protected] sip:[email protected]
Connecting to peer DeviceBuilder {
_devices: [
[
{
type: 'sip',
from: 'sip:[email protected]',
to: 'sip:[email protected]:20003;transport=tcp',
timeout: 30
}
]
]
}
B Call connected! id = undefined
hello
Error connecting call: Error: Can't call play() on a call not established yet.
at /Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4254:16
at new Promise (<anonymous>)
at CallConsumer.play (/Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4252:12)
at CallConsumer.playTTS (/Users/seven/work/call-translator/js/node_modules/@signalwire/realtime-api/dist/index.node.js:4301:17)
at EventEmitter.<anonymous> (/Users/seven/work/call-translator/js/connect-tts.js:27:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
waiting b leg to end
waiting a leg to end
done
The text was updated successfully, but these errors were encountered:
sometimes I get an error when I immediately call play on a connected call. the call is successfully connected but looks like the state is not updated before I run play, and there's no function to wait for the state. Adding a sleep helps before play.
js:
package.json
full log:
The text was updated successfully, but these errors were encountered: