@@ -113,35 +113,44 @@ describe('speech_to_text_integration', function() {
113
113
speech_to_text . getModels ( { } , done ) ;
114
114
} ) ;
115
115
116
- it ( 'createRecognizeStream()' , function ( done ) {
117
- const recognizeStream = speech_to_text . createRecognizeStream ( {
118
- content_type : 'audio/l16; rate=44100'
116
+ describe ( 'createRecognizeStream()' , ( ) => {
117
+ it ( 'transcribes audio over a websocket' , function ( done ) {
118
+ const recognizeStream = speech_to_text . createRecognizeStream ( ) ;
119
+ recognizeStream . setEncoding ( 'utf8' ) ;
120
+ fs . createReadStream ( path . join ( __dirname , '../resources/weather.flac' ) ) . pipe ( recognizeStream ) . on ( 'error' , done ) . pipe (
121
+ concat ( function ( transcription ) {
122
+ assert . equal ( typeof transcription , 'string' , 'should return a string transcription' ) ;
123
+ assert . equal ( transcription . trim ( ) , 'thunderstorms could produce large hail isolated tornadoes and heavy rain' ) ;
124
+ done ( ) ;
125
+ } )
126
+ ) ;
119
127
} ) ;
120
- recognizeStream . setEncoding ( 'utf8' ) ;
121
- fs . createReadStream ( path . join ( __dirname , '../resources/weather.flac' ) ) . pipe ( recognizeStream ) . on ( 'error' , done ) . pipe (
122
- concat ( function ( transcription ) {
123
- assert . equal ( typeof transcription , 'string' , 'should return a string transcription' ) ;
124
- assert . equal ( transcription . trim ( ) , 'thunderstorms could produce large hail isolated tornadoes and heavy rain' ) ;
125
- done ( ) ;
126
- } )
127
- ) ;
128
- } ) ;
129
128
130
- it ( 'createRecognizeStream() - no words' , function ( done ) {
131
- const recognizeStream = speech_to_text . createRecognizeStream ( {
132
- content_type : 'audio/l16; rate=44100'
129
+ it ( 'works when stream has no words' , function ( done ) {
130
+ const recognizeStream = speech_to_text . createRecognizeStream ( {
131
+ content_type : 'audio/l16; rate=44100'
132
+ } ) ;
133
+ recognizeStream . setEncoding ( 'utf8' ) ;
134
+ fs
135
+ . createReadStream ( path . join ( __dirname , '../resources/blank.wav' ) )
136
+ . pipe ( recognizeStream )
137
+ . on ( 'error' , done )
138
+ . on ( 'data' , function ( text ) {
139
+ assert ( ! text , 'no text expected for an audio file with no words' ) ;
140
+ } )
141
+ . on ( 'end' , done ) ;
133
142
} ) ;
134
- recognizeStream . setEncoding ( 'utf8' ) ;
135
- fs
136
- . createReadStream ( path . join ( __dirname , '../resources/blank.wav' ) )
137
- . pipe ( recognizeStream )
138
- . on ( 'error' , done )
139
- . on ( 'data' , function ( text ) {
140
- assert ( ! text , 'no text expected for an audio file with no words' ) ;
141
- } )
142
- . on ( 'end' , done ) ;
143
+
144
+ it ( 'exposes Transaction ID in node.js' , ( ) => {
145
+ const recognizeStream = speech_to_text . createRecognizeStream ( ) ;
146
+ return fs . createReadStream ( path . join ( __dirname , '../resources/weather.ogg' ) )
147
+ . pipe ( recognizeStream )
148
+ . getTransactionId ( )
149
+ . then ( id => assert ( id ) ) ;
150
+ } )
143
151
} ) ;
144
152
153
+
145
154
describe ( 'customization' , function ( ) {
146
155
let customization_id ;
147
156
0 commit comments