Skip to content

Commit 78c863c

Browse files
committed
Fixed spaces
1 parent f25b1e9 commit 78c863c

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

audio.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import multiprocessing
77
import pprint
88
import csv
9-
import new_filter_function
109
import threading
1110
import googleapiclient
1211
from collections import Counter
@@ -127,10 +126,10 @@ def text_to_num(num, source_name="", results_dict={}):
127126
def sphinx(audio, vals, i, results_dict, timing):
128127
try:
129128
#print("Sphinx: ")
130-
s = time.time()
129+
s = time.time()
131130
vals[i] = text_to_num(r.recognize_sphinx(audio), "sphinx", results_dict)
132-
timing["sphinx"].append(time.time() - s)
133-
print "timing2", timing
131+
timing["sphinx"].append(time.time() - s)
132+
print "timing2", timing
134133
except sr.UnknownValueError:
135134
logging.debug("Sphinx could not understand audio")
136135
results_dict["sphinx"] = [DEFAULT]
@@ -156,12 +155,13 @@ def googleCloud(audio, vals, i, results_dict, timing):
156155
}"""
157156
try:
158157
s = time.time()
159-
#print("Google Cloud Speech: ")
158+
#print("Google Cloud Speech: ")
160159
vals[i] = text_to_num(r.recognize_google_cloud(audio, \
161-
preferred_phrases=["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],\
162-
credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS), "googleCloud", results_dict)
163-
timing["googleCloud"].append(time.time() - s)
164-
print "timing", timing["googleCloud"]
160+
preferred_phrases=["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],\
161+
credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS), "googleCloud", results_dict)
162+
163+
timing["googleCloud"].append(time.time() - s)
164+
print "timing", timing["googleCloud"]
165165
#print("Google Cloud " + str(vals[i]))
166166
except sr.UnknownValueError:
167167
logging.debug("Google Cloud Speech could not understand audio")
@@ -171,17 +171,17 @@ def googleCloud(audio, vals, i, results_dict, timing):
171171
logging.debug("Could not request results from Google Cloud Speech service; {0}".format(e))
172172
results_dict["googleCloud"] = [DEFAULT]
173173
results_dict["googleCloud_fil"] = [DEFAULT]
174-
except:
175-
pass
174+
except:
175+
pass
176176
#Query Wit
177177
def wit(audio, vals, i, results_dict, timing):
178178
# recognize speech using Wit.ai
179179
WIT_AI_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx" # Wit.ai keys are 32-character uppercase alphanumeric strings
180180
try:
181-
s = time.time()
181+
s = time.time()
182182
#print("Wit.ai: ")
183183
vals[i] = text_to_num(r.recognize_wit(audio, key=WIT_AI_KEY), "wit", results_dict)
184-
timing["wit"].append(time.time() - s)
184+
timing["wit"].append(time.time() - s)
185185
#print("Wit " + str(vals[i]))
186186
except sr.UnknownValueError:
187187
logging.debug("Wit.ai could not understand audio")
@@ -198,10 +198,10 @@ def bing(audio, vals, i, results_dict, timing):
198198

199199
BING_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
200200
try:
201-
s = time.time()
201+
s = time.time()
202202
#print("Microsoft Bing Voice Recognition: ")
203203
vals[i] = text_to_num(r.recognize_bing(audio, key=BING_KEY), "bing", results_dict)
204-
timing["bing"].append(time.time() - s)
204+
timing["bing"].append(time.time() - s)
205205
except sr.UnknownValueError:
206206
logging.debug("Microsoft Bing Voice Recognition could not understand audio")
207207
results_dict["bing"] = [DEFAULT]
@@ -216,11 +216,11 @@ def ibm(audio, vals, i, results_dict, timing, show_all=False):
216216
IBM_USERNAME = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" # IBM Speech to Text usernames are strings of the form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
217217
IBM_PASSWORD = "XXXXXXXXXX" # IBM Speech to Text passwords are mixed-case alphanumeric strings
218218
try:
219-
s = time.time()
219+
s = time.time()
220220
#print("IBM Speech to Text: ")
221221
vals[i] = text_to_num(r.recognize_ibm(audio, username=IBM_USERNAME, \
222-
password=IBM_PASSWORD, show_all=False), "ibm", results_dict)
223-
timing["ibm"].append(time.time() - s)
222+
password=IBM_PASSWORD, show_all=False), "ibm", results_dict)
223+
timing["ibm"].append(time.time() - s)
224224
except sr.UnknownValueError:
225225
logging.debug("IBM Speech to Text could not understand audio")
226226
results_dict["ibm"] = [DEFAULT]
@@ -233,9 +233,9 @@ def ibm(audio, vals, i, results_dict, timing, show_all=False):
233233
def google(audio, vals, i, results_dict, timing):
234234
try:
235235
#print("Google: ")
236-
s= time.time()
236+
s= time.time()
237237
vals[i] = text_to_num(r.recognize_google(audio), "google", results_dict)
238-
timing["google"].append(time.time() - s)
238+
timing["google"].append(time.time() - s)
239239
except:
240240
logging.debug("Google could not understand")
241241
results_dict["google"] = [DEFAULT]
@@ -365,9 +365,9 @@ def getNum(audio_file, results_dict, digit_num=0, ans=[]):
365365
results_dict_threaded = manage_vars.dict()
366366
results = []
367367
threads = []
368-
timed = manage_vars.dict()
369-
for api in apis:
370-
timed[api] = manage_vars.list()
368+
timed = manage_vars.dict()
369+
for api in apis:
370+
timed[api] = manage_vars.list()
371371
apis_func = [googleCloud, sphinx, wit, bing, google, ibm]
372372
i = 0
373373
start = time.time()
@@ -379,7 +379,7 @@ def getNum(audio_file, results_dict, digit_num=0, ans=[]):
379379

380380
for thread in threads:
381381
thread.join()
382-
end = time.time()
382+
end = time.time()
383383
print "getnumtime", end-start
384384
print timed
385385
results_dict["time" + str(digit_num)] = end - start
@@ -404,14 +404,14 @@ def getNum(audio_file, results_dict, digit_num=0, ans=[]):
404404
results = sorted(results, key=results.count, reverse=True)
405405
if not results:
406406
logging.debug("FOUND NOTHING")
407-
ans[digit_num] = DEFAULT
407+
ans[digit_num] = DEFAULT
408408
return DEFAULT
409409
else:
410410
# print(results[0])
411411
logging.info("DETERMINED AS: " + str(results[0]))
412-
print ans
413-
print digit_num
414-
ans[digit_num] = results[0]
412+
print ans
413+
print digit_num
414+
ans[digit_num] = results[0]
415415
return results[0]
416416

417417
def test_dir(directory):

main.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import os
1515
import urllib
1616
import time
17-
import ris
1817
import audio
1918
import threading
2019
import argparse

0 commit comments

Comments
 (0)