@@ -893,25 +893,19 @@ def recognize_google(self, audio_data, key=None, language="en-US", pfilter=0, sh
893
893
except URLError as e :
894
894
raise RequestError ("recognition connection failed: {}" .format (e .reason ))
895
895
response_text = response .read ().decode ("utf-8" )
896
- # print('response_text:')
897
- # pprint(response_text, indent=4)
898
896
899
897
# ignore any blank blocks
900
898
actual_result = []
901
899
for line in response_text .split ("\n " ):
902
900
if not line : continue
903
- result = json .loads (line )["result" ]
904
- # print('result1:')
905
- # pprint(result, indent=4)
901
+ result = json .loads (line )["result" ]
906
902
if len (result ) != 0 :
907
903
actual_result = result [0 ]
908
904
break
909
905
910
906
# return results
911
907
if show_all :
912
908
return actual_result
913
- # print('result2:')
914
- # pprint(actual_result, indent=4)
915
909
916
910
if not isinstance (actual_result , dict ) or len (actual_result .get ("alternative" , [])) == 0 : raise UnknownValueError ()
917
911
@@ -1125,8 +1119,6 @@ def recognize_azure(self, audio_data, key, language="en-US", profanity="masked",
1125
1119
result = json .loads (response_text )
1126
1120
1127
1121
# return results
1128
- # print('result:')
1129
- # pprint(result, indent=4)
1130
1122
if show_all :
1131
1123
return result
1132
1124
if "RecognitionStatus" not in result or result ["RecognitionStatus" ] != "Success" or "NBest" not in result :
@@ -1306,8 +1298,6 @@ def recognize_houndify(self, audio_data, client_id, client_key, show_all=False):
1306
1298
1307
1299
# return results
1308
1300
if show_all : return result
1309
- # print('result:')
1310
- # pprint(result, indent=4)
1311
1301
if "Disambiguation" not in result or result ["Disambiguation" ] is None :
1312
1302
raise UnknownValueError ()
1313
1303
return result ['Disambiguation' ]['ChoiceData' ][0 ]['Transcription' ], result ['Disambiguation' ]['ChoiceData' ][0 ]['ConfidenceScore' ]
@@ -1396,17 +1386,13 @@ def recognize_amazon(self, audio_data, bucket_name=None, access_key_id=None, sec
1396
1386
raise
1397
1387
1398
1388
job = status ['TranscriptionJob' ]
1399
- # print('status0:')
1400
- # pprint(status, indent=4)
1401
1389
if job ['TranscriptionJobStatus' ] in ['COMPLETED' ] and 'TranscriptFileUri' in job ['Transcript' ]:
1402
1390
1403
1391
# Retrieve transcription JSON containing transcript.
1404
1392
transcript_uri = job ['Transcript' ]['TranscriptFileUri' ]
1405
1393
import urllib .request , json
1406
1394
with urllib .request .urlopen (transcript_uri ) as json_data :
1407
1395
d = json .load (json_data )
1408
- # print('result:')
1409
- # pprint(d, indent=4)
1410
1396
confidences = []
1411
1397
for item in d ['results' ]['items' ]:
1412
1398
confidences .append (float (item ['alternatives' ][0 ]['confidence' ]))
@@ -1507,7 +1493,6 @@ def read_file(filename, chunk_size=5242880):
1507
1493
}
1508
1494
response = requests .get (endpoint , headers = headers )
1509
1495
data = response .json ()
1510
- # print('Raw response: %s' % data)
1511
1496
status = data ['status' ]
1512
1497
1513
1498
if status == 'error' :
@@ -1534,9 +1519,7 @@ def read_file(filename, chunk_size=5242880):
1534
1519
response = requests .post ('https://api.assemblyai.com/v2/upload' ,
1535
1520
headers = headers ,
1536
1521
data = read_file (audio_data ))
1537
- # print(response.json())
1538
1522
upload_url = response .json ()['upload_url' ]
1539
- # print('upload_url:', upload_url)
1540
1523
1541
1524
# Queue file for transcription.
1542
1525
endpoint = "https://api.assemblyai.com/v2/transcript"
@@ -1549,7 +1532,6 @@ def read_file(filename, chunk_size=5242880):
1549
1532
}
1550
1533
response = requests .post (endpoint , json = json , headers = headers )
1551
1534
data = response .json ()
1552
- # print(data)
1553
1535
transciption_id = data ['id' ]
1554
1536
exc = TranscriptionNotReady ()
1555
1537
exc .job_name = transciption_id
@@ -1596,8 +1578,6 @@ def recognize_ibm(self, audio_data, key, language="en-US", show_all=False):
1596
1578
# return results
1597
1579
if show_all :
1598
1580
return result
1599
- # print('result:')
1600
- # pprint(result, indent=4)
1601
1581
if "results" not in result or len (result ["results" ]) < 1 or "alternatives" not in result ["results" ][0 ]:
1602
1582
raise UnknownValueError ()
1603
1583
0 commit comments