Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice is not coming from server to phone on EC2 deployment | Working on local environment #44

Open
BhargabSixthSens opened this issue Jun 25, 2024 · 2 comments

Comments

@BhargabSixthSens
Copy link

Hi, I am facing an issue.
When I deploy this to EC2 voice is not coming from server to my phone.
It is working on local environment.
I am getting response from gpt and text to speech service is also working I think.

What could be the issue?

@BhargabSixthSens BhargabSixthSens changed the title Voice is not coming from server to phone on EC2 deployment Voice is not coming from server to phone on EC2 deployment | Working on local environment Jun 25, 2024
@vbstm93
Copy link

vbstm93 commented Aug 6, 2024

Hello, @BhargabSixthSens

I have the same result, I make the connection and it completes and connects but it is silent on the gpt side.

@MaxySpark
Copy link

MaxySpark commented Aug 8, 2024

This is due to start event is not coming in hosted server.
For some reason first few events are missing. so you will miss connected and start event.
So the following code won't execute

if (msg.event === 'start') {
        streamSid = msg.start.streamSid;
        callSid = msg.start.callSid;
        
        streamService.setStreamSid(streamSid);
        gptService.setCallSid(callSid);

        // Set RECORDING_ENABLED='true' in .env to record calls
        recordingService(ttsService, callSid).then(() => {
          console.log(`Twilio -> Starting Media Stream for ${streamSid}`.underline.red);
          ttsService.generate({partialResponseIndex: null, partialResponse: 'Hello! I understand you\'re looking for a pair of AirPods, is that correct?'}, 0);
        });
      }

One workaround I found

You can pass the callSid from body as a param in wss link here

And here you can pass a second param (ws, req)

use req to get params and callSid

wss://${process.env.SERVER}/connection/${req.body.callSid}

app.ws('/connection/:callSid', (ws,req) => {

const {callSid} = req.params;
...

use callSid to set gpservice callSid
and in media event you will get streamSid set it in streamService
something like this

else if (msg.event === 'media') {
   if (!streamService.streamSid) {
        streamService.setStreamSid(msg.streamSid);
        recordingService(ttsService, callSid).then(() => {
          console.log(`Twilio -> Starting Media Stream for ${streamSid}`.underline.red);
          ttsService.generate({partialResponseIndex: null, partialResponse: 'Hello! I understand you\'re looking for a pair of AirPods, is that correct?'}, 0);
        });
    }
    transcriptionService.send(msg.media.payload);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants