Commit da3f2b4c authored by pbethge's avatar pbethge
Browse files

add time measurement

parent ca98b8e9
......@@ -53,16 +53,28 @@ def processAudio(config, q):
data_tensor = torch.tensor(data, dtype=float)
data_tensor = torch.unsqueeze(data_tensor, 0)
start = time.time()
out = model.classify_batch(data_tensor)
language = out[3][0]
print(language)
endtime_batch = time.time() - start
# classification from file is also possible
# results = model.classify_file("test.wav")
# if out[index] >= lid_threshold:
# print(classes[index])
fname = str(time.ctime(time.time())) + "_" + language + '.wav'
wav.write(fname, SAMPLE_RATE, np.asarray(data))
if torch.cuda.is_available():
print("GPU runtime from batch: " + str(endtime_batch))
else:
print("CPU runtime from batch: " + str(endtime_batch))
print(language)
except Exception as e:
print("Ooopsi: ", e)
q.task_done()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment