Skip to content

Commit 7379a84

Browse files
author
kuzmoyev
committed
Remove debugging prints
1 parent 80bafbd commit 7379a84

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

speech_recognition/__init__.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -893,25 +893,19 @@ def recognize_google(self, audio_data, key=None, language="en-US", pfilter=0, sh
893893
except URLError as e:
894894
raise RequestError("recognition connection failed: {}".format(e.reason))
895895
response_text = response.read().decode("utf-8")
896-
# print('response_text:')
897-
# pprint(response_text, indent=4)
898896

899897
# ignore any blank blocks
900898
actual_result = []
901899
for line in response_text.split("\n"):
902900
if not line: continue
903-
result = json.loads(line)["result"]
904-
# print('result1:')
905-
# pprint(result, indent=4)
901+
result = json.loads(line)["result"]
906902
if len(result) != 0:
907903
actual_result = result[0]
908904
break
909905

910906
# return results
911907
if show_all:
912908
return actual_result
913-
# print('result2:')
914-
# pprint(actual_result, indent=4)
915909

916910
if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()
917911

@@ -1125,8 +1119,6 @@ def recognize_azure(self, audio_data, key, language="en-US", profanity="masked",
11251119
result = json.loads(response_text)
11261120

11271121
# return results
1128-
# print('result:')
1129-
# pprint(result, indent=4)
11301122
if show_all:
11311123
return result
11321124
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):
13061298

13071299
# return results
13081300
if show_all: return result
1309-
# print('result:')
1310-
# pprint(result, indent=4)
13111301
if "Disambiguation" not in result or result["Disambiguation"] is None:
13121302
raise UnknownValueError()
13131303
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
13961386
raise
13971387

13981388
job = status['TranscriptionJob']
1399-
# print('status0:')
1400-
# pprint(status, indent=4)
14011389
if job['TranscriptionJobStatus'] in ['COMPLETED'] and 'TranscriptFileUri' in job['Transcript']:
14021390

14031391
# Retrieve transcription JSON containing transcript.
14041392
transcript_uri = job['Transcript']['TranscriptFileUri']
14051393
import urllib.request, json
14061394
with urllib.request.urlopen(transcript_uri) as json_data:
14071395
d = json.load(json_data)
1408-
# print('result:')
1409-
# pprint(d, indent=4)
14101396
confidences = []
14111397
for item in d['results']['items']:
14121398
confidences.append(float(item['alternatives'][0]['confidence']))
@@ -1507,7 +1493,6 @@ def read_file(filename, chunk_size=5242880):
15071493
}
15081494
response = requests.get(endpoint, headers=headers)
15091495
data = response.json()
1510-
# print('Raw response: %s' % data)
15111496
status = data['status']
15121497

15131498
if status == 'error':
@@ -1534,9 +1519,7 @@ def read_file(filename, chunk_size=5242880):
15341519
response = requests.post('https://api.assemblyai.com/v2/upload',
15351520
headers=headers,
15361521
data=read_file(audio_data))
1537-
# print(response.json())
15381522
upload_url = response.json()['upload_url']
1539-
# print('upload_url:', upload_url)
15401523

15411524
# Queue file for transcription.
15421525
endpoint = "https://api.assemblyai.com/v2/transcript"
@@ -1549,7 +1532,6 @@ def read_file(filename, chunk_size=5242880):
15491532
}
15501533
response = requests.post(endpoint, json=json, headers=headers)
15511534
data = response.json()
1552-
# print(data)
15531535
transciption_id = data['id']
15541536
exc = TranscriptionNotReady()
15551537
exc.job_name = transciption_id
@@ -1596,8 +1578,6 @@ def recognize_ibm(self, audio_data, key, language="en-US", show_all=False):
15961578
# return results
15971579
if show_all:
15981580
return result
1599-
# print('result:')
1600-
# pprint(result, indent=4)
16011581
if "results" not in result or len(result["results"]) < 1 or "alternatives" not in result["results"][0]:
16021582
raise UnknownValueError()
16031583

0 commit comments

Comments
 (0)