@@ -207,21 +207,20 @@ def recognize_using_websocket(self,
207
207
raise Exception (
208
208
'Callback is not a derived class of RecognizeCallback' )
209
209
210
+ request = {}
211
+
210
212
headers = {}
211
213
if self .default_headers is not None :
212
214
headers = self .default_headers .copy ()
213
215
if 'headers' in kwargs :
214
216
headers .update (kwargs .get ('headers' ))
217
+ request ['headers' ] = headers
215
218
216
- if self .token_manager :
217
- access_token = self .token_manager .get_token ()
218
- headers ['Authorization' ] = '{0} {1}' .format (BEARER , access_token )
219
- else :
220
- authstring = "{0}:{1}" .format (self .username , self .password )
221
- base64_authorization = base64 .b64encode (authstring .encode ('utf-8' )).decode ('utf-8' )
222
- headers ['Authorization' ] = 'Basic {0}' .format (base64_authorization )
219
+ if self .authenticator :
220
+ self .authenticator .authenticate (request )
223
221
224
222
url = self .url .replace ('https:' , 'wss:' )
223
+
225
224
params = {
226
225
'model' : model ,
227
226
'customization_id' : customization_id ,
@@ -232,6 +231,7 @@ def recognize_using_websocket(self,
232
231
}
233
232
params = dict ([(k , v ) for k , v in params .items () if v is not None ])
234
233
url += '/v1/recognize?{0}' .format (urlencode (params ))
234
+ request ['url' ] = url
235
235
236
236
options = {
237
237
'content_type' : content_type ,
@@ -253,12 +253,13 @@ def recognize_using_websocket(self,
253
253
'audio_metrics' : audio_metrics
254
254
}
255
255
options = dict ([(k , v ) for k , v in options .items () if v is not None ])
256
+ request ['options' ] = options
256
257
257
258
RecognizeListener (audio ,
258
- options ,
259
+ request . get ( ' options' ) ,
259
260
recognize_callback ,
260
- url ,
261
- headers ,
261
+ request . get ( ' url' ) ,
262
+ request . get ( ' headers' ) ,
262
263
http_proxy_host ,
263
264
http_proxy_port ,
264
- self .verify )
265
+ self .disable_ssl_verification )
0 commit comments