-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
in this code block: https://github.com/twilio-labs/call-gpt/blob/main/services/transcription-service.js#L46
// console.log(text, "is_final: ", transcription?.is_final, "speech_final: ", transcription.speech_final);
// if is_final that means that this chunk of the transcription is accurate and we need to add it to the finalResult
if (transcriptionEvent.is_final === true && text.trim().length > 0) {
this.finalResult += ` ${text}`;
// if speech_final and is_final that means this text is accurate and it's a natural pause in the speakers speech. We need to send this to the assistant for processing
if (transcriptionEvent.speech_final === true) {
this.speechFinal = true; // this will prevent a utterance end which shows up after speechFinal from sending another response
this.emit('transcription', this.finalResult);
this.finalResult = '';
} else {
// if we receive a message without speechFinal reset speechFinal to false, this will allow any subsequent utteranceEnd messages to properly indicate the end of a message
this.speechFinal = false;
}
} else {
this.emit('utterance', text);
}
});
you can get into a loop where the console.log output looks like this:
is_final: false speech_final: false
is_final: false speech_final: false
is_final: true speech_final: false
is_final: false speech_final: false
is_final: true speech_final: true
is_final: false speech_final: false
Where the speech_final is true but NO transcription event is emitted, even though there is content in the finalResult.
Metadata
Metadata
Assignees
Labels
No labels