@@ -4,7 +4,6 @@ const assert = require('assert');
44const watson = require ( '../../index' ) ;
55const nock = require ( 'nock' ) ;
66const fs = require ( 'fs' ) ;
7- const extend = require ( 'extend' ) ;
87const isStream = require ( 'isstream' ) ;
98
109describe ( 'speech_to_text' , function ( ) {
@@ -136,58 +135,16 @@ describe('speech_to_text', function() {
136135 } ) ;
137136
138137 describe ( 'recognize()' , function ( ) {
139- const path = '/v1/recognize' ;
140- const session_path = '/v1/sessions/foo/recognize' ;
141- const payload = {
142- audio : fs . createReadStream ( __dirname + '/../resources/weather.wav' ) ,
143- content_type : 'audio/l16;rate=41100' ,
144- } ;
145-
146138 it ( 'should check no parameters provided' , function ( ) {
147139 speech_to_text . recognize ( { } , missingParameter ) ;
148140 speech_to_text . recognize ( null , missingParameter ) ;
149141 speech_to_text . recognize ( { audio : 'foo' } , missingParameter ) ;
150142 speech_to_text . recognize ( { content_type : 'bar' } , missingParameter ) ;
151143 speech_to_text . recognize ( { continuous : 'false' } , missingParameter ) ;
152144 } ) ;
153-
154- it ( 'should generate a valid payload with session' , function ( ) {
155- const req = speech_to_text . recognize ( extend ( { session_id : 'foo' } , payload ) , noop ) ;
156- assert . equal ( req . uri . href , service . url + session_path ) ;
157- assert . equal ( req . method , 'POST' ) ;
158- assert . equal ( req . headers [ 'Content-Type' ] , payload . content_type ) ;
159- assert . equal ( req . src . path , payload . audio . path ) ;
160- } ) ;
161-
162- it ( 'should generate a valid payload without session' , function ( ) {
163- const req = speech_to_text . recognize ( payload , noop ) ;
164- assert . equal ( req . uri . href , service . url + path ) ;
165- assert . equal ( req . method , 'POST' ) ;
166- assert . equal ( req . headers [ 'Content-Type' ] , payload . content_type ) ;
167- assert . equal ( req . src . path , payload . audio . path ) ;
168- } ) ;
169-
170- it ( 'should accept an array of keywords' , function ( ) {
171- const req = speech_to_text . recognize ( extend ( { keywords : [ 'a' , 'b' , 'c' ] } , payload ) , noop ) ;
172- assert . equal ( req . uri . query , 'keywords=' + encodeURIComponent ( 'a,b,c' ) ) ;
173- } ) ;
174145 } ) ;
175146
176147 describe ( 'recognizeWebM()' , function ( ) {
177- it ( 'should generate a valid payload with session' , function ( ) {
178- const webm_stream = fs . createReadStream ( __dirname + '/../resources/sample1.webm' ) ;
179- const session_path = '/v1/sessions/foo/recognize' ;
180- const payload = {
181- audio : webm_stream ,
182- content_type : 'audio/webm' ,
183- } ;
184- const req = speech_to_text . recognize ( extend ( { session_id : 'foo' } , payload ) , noop ) ;
185- assert . equal ( req . uri . href , service . url + session_path ) ;
186- assert . equal ( req . method , 'POST' ) ;
187- assert . equal ( req . headers [ 'Content-Type' ] , payload . content_type ) ;
188- assert . equal ( req . src . path , payload . audio . path ) ;
189- } ) ;
190-
191148 it ( 'Sample webm should have expected header' , function ( ) {
192149 const RecognizeStream = require ( '../../lib/recognize-stream' ) ;
193150 const buffer = fs . readFileSync ( __dirname + '/../resources/sample1.webm' ) ;
0 commit comments