@@ -55,6 +55,9 @@ function syncRecognize (filename, encoding, sampleRateHertz, languageCode) {
55
55
const transcription = results [ 0 ] ;
56
56
57
57
console . log ( `Transcription: ${ transcription } ` ) ;
58
+ } )
59
+ . catch ( ( err ) => {
60
+ console . error ( 'ERROR:' , err ) ;
58
61
} ) ;
59
62
// [END speech_sync_recognize]
60
63
}
@@ -91,6 +94,9 @@ function syncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
91
94
const transcription = results [ 0 ] ;
92
95
93
96
console . log ( `Transcription: ${ transcription } ` ) ;
97
+ } )
98
+ . catch ( ( err ) => {
99
+ console . error ( 'ERROR:' , err ) ;
94
100
} ) ;
95
101
// [END speech_sync_recognize_gcs]
96
102
}
@@ -131,6 +137,9 @@ function asyncRecognize (filename, encoding, sampleRateHertz, languageCode) {
131
137
} )
132
138
. then ( ( transcription ) => {
133
139
console . log ( `Transcription: ${ transcription } ` ) ;
140
+ } )
141
+ . catch ( ( err ) => {
142
+ console . error ( 'ERROR:' , err ) ;
134
143
} ) ;
135
144
// [END speech_async_recognize]
136
145
}
@@ -171,6 +180,9 @@ function asyncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
171
180
} )
172
181
. then ( ( transcription ) => {
173
182
console . log ( `Transcription: ${ transcription } ` ) ;
183
+ } )
184
+ . catch ( ( err ) => {
185
+ console . error ( 'ERROR:' , err ) ;
174
186
} ) ;
175
187
// [END speech_async_recognize_gcs]
176
188
}
@@ -209,7 +221,7 @@ function streamingRecognize (filename, encoding, sampleRateHertz, languageCode)
209
221
const recognizeStream = speech . createRecognizeStream ( request )
210
222
. on ( 'error' , console . error )
211
223
. on ( 'data' , ( data ) => {
212
- console . log ( 'Data received: %j' , data ) ;
224
+ console . log ( `Transcription: ${ data . results } ` ) ;
213
225
} ) ;
214
226
215
227
// Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw"
0 commit comments