File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -83,34 +83,33 @@ async function generateContent(
8383 async function handleTurn ( ) {
8484 const audioFrames = [ ] ;
8585 let done = false ;
86- //todo
86+
8787 while ( ! done ) {
8888 const message = await waitMessage ( ) ;
8989 const sc = message . serverContent ;
9090
91- if ( sc ? .inputTranscription ) {
91+ if ( sc && sc . inputTranscription ) {
9292 console . log ( 'Input transcription' , sc . inputTranscription ) ;
9393 }
94- if ( sc ? .outputTranscription ) {
94+ if ( sc && sc . outputTranscription ) {
9595 console . log ( 'Output transcription' , sc . outputTranscription ) ;
9696 }
97- if ( sc ? .modelTurn ? .parts ) {
97+ if ( sc && sc . modelTurn && sc . modelTurn . parts ) {
9898 for ( const part of sc . modelTurn . parts ) {
99- if ( part . inlineData ? .data ) {
99+ if ( part && part . inlineData && part . inlineData . data ) {
100100 const audioData = Buffer . from ( part . inlineData . data , 'base64' ) ;
101101 audioFrames . push ( audioData ) ;
102102 }
103103 }
104104 }
105- if ( sc ? .turnComplete ) {
105+ if ( sc && sc . turnComplete ) {
106106 done = true ;
107107 }
108108 }
109109
110110 return audioFrames ;
111111 }
112112
113-
114113 const session = await client . live . connect ( {
115114 model : MODEL ,
116115 config : {
@@ -148,7 +147,7 @@ async function generateContent(
148147 OUTPUT_RATE
149148 ) ;
150149 }
151-
150+ //todo petla
152151 await session . close ( ) ;
153152 return audioFrames ;
154153}
You can’t perform that action at this time.
0 commit comments