File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed
Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -61,16 +61,20 @@ async function generateLiveConversation(
6161 while ( ! done ) {
6262 const message = await waitMessage ( ) ;
6363
64- const sc = message . serverContent ;
65- if ( sc && sc . modelTurn && sc . modelTurn . parts ) {
66- for ( const part of sc . modelTurn . parts ) {
64+ const serverContent = message . serverContent ;
65+ if (
66+ serverContent &&
67+ serverContent . modelTurn &&
68+ serverContent . modelTurn . parts
69+ ) {
70+ for ( const part of serverContent . modelTurn . parts ) {
6771 if ( part && part . inlineData && part . inlineData . data ) {
6872 audioChunks . push ( Buffer . from ( part . inlineData . data ) ) ;
6973 }
7074 }
7175 }
7276
73- if ( sc && sc . turnComplete ) {
77+ if ( serverContent && serverContent . turnComplete ) {
7478 done = true ;
7579 }
7680 }
Original file line number Diff line number Diff line change @@ -55,17 +55,21 @@ async function generateLiveAudioTranscription(
5555 const message = await waitMessage ( ) ;
5656 turns . push ( message ) ;
5757
58- const sc = message . serverContent ;
59- if ( sc && sc . modelTurn ) {
60- console . log ( 'Model turn:' , sc . modelTurn ) ;
58+ const serverContent = message . serverContent ;
59+ if ( serverContent && serverContent . modelTurn ) {
60+ console . log ( 'Model turn:' , serverContent . modelTurn ) ;
6161 }
62- if ( sc && sc . inputTranscription ) {
63- console . log ( 'Input transcript:' , sc . inputTranscription . text ) ;
62+ if ( serverContent && serverContent . inputTranscription ) {
63+ console . log ( 'Input transcript:' , serverContent . inputTranscription . text ) ;
6464 }
65- if ( sc && sc . outputTranscription && sc . outputTranscription . text ) {
66- outputMessage . push ( sc . outputTranscription . text ) ;
65+ if (
66+ serverContent &&
67+ serverContent . outputTranscription &&
68+ serverContent . outputTranscription . text
69+ ) {
70+ outputMessage . push ( serverContent . outputTranscription . text ) ;
6771 }
68- if ( sc && sc . turnComplete ) {
72+ if ( serverContent && serverContent . turnComplete ) {
6973 done = true ;
7074 }
7175 }
You can’t perform that action at this time.
0 commit comments