File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
examples/twilio/src/streams Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,32 @@ import { webSocketConnect } from "./connect";
33import { DeepgramTextToSpeech } from "../functions/deepgram/textToSpeech" ;
44import { v4 as uuidv4 } from "uuid" ;
55import { StreamInput } from "./audioToText" ;
6+ import { TrackName } from "../workflows" ;
67
78export async function streamTextToAudio ( { streamSid, trackName } : StreamInput ) {
89 return new Promise < void > ( async ( resolve , reject ) => {
910 const ws = await webSocketConnect ( ) ;
1011
1112 const textToSpeech = new DeepgramTextToSpeech ( ) ;
1213
13- textToSpeech . generate ( {
14+ const welcomeMessage = {
1415 gptReply : {
1516 partialResponseIndex : null ,
1617 partialResponse :
1718 "Hello! My name is Emilia from Apple. You are interested in Airpods, is that correct?" ,
1819 } ,
1920 interactionCount : 0 ,
20- trackName : "agent" ,
21- } ) ;
21+ trackName : "agent" as TrackName ,
22+ } ;
23+
24+ textToSpeech . generate ( welcomeMessage ) ;
25+
26+ const event = {
27+ streamSid,
28+ event : "answer" ,
29+ data : welcomeMessage ,
30+ } ;
31+ ws . send ( JSON . stringify ( event ) ) ;
2232
2333 ws . on ( "message" , ( data ) => {
2434 const message = JSON . parse ( data . toString ( ) ) ;
You can’t perform that action at this time.
0 commit comments