summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-15 15:20:25 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-25 20:09:22 +0200
commit78f0b5b8344dad427902b84210dc4d217c9d9205 (patch)
treeb80fa459cdb1edc03b298acac6c63568cb224d66
parent8eed677c0a05e124883ab216b8fd0d6957dfb4b3 (diff)
downloadjasper-client-78f0b5b8344dad427902b84210dc4d217c9d9205.tar.gz
jasper-client-78f0b5b8344dad427902b84210dc4d217c9d9205.zip
Use with statement to open file in Google STT engine
-rw-r--r--client/stt.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/client/stt.py b/client/stt.py
index a83b6c7..1960a4b 100644
--- a/client/stt.py
+++ b/client/stt.py
@@ -186,9 +186,8 @@ class GoogleSTT(AbstractSTTEngine):
url = "https://www.google.com/speech-api/v2/recognize?output=json&client=chromium&key=%s&lang=%s&maxresults=6&pfilter=2" % (
self.api_key, "en-us")
- wav = open(audio_file_path, 'rb')
- data = wav.read()
- wav.close()
+ with open(audio_file_path, 'rb') as f:
+ data = f.read()
try:
headers = {'Content-type': 'audio/l16; rate=%s' % GoogleSTT.RATE}