Spaces:
Runtime error
Runtime error
aac support in recognizing
Browse files- app.py +1 -1
- routes/witaiApi/recognizeVoice.py +12 -4
app.py
CHANGED
|
@@ -84,7 +84,7 @@ def getBMPreview(): return osuApi.getPreview(request)
|
|
| 84 |
def getBMFull(): return osuApi.getFull(request)
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|
| 87 |
-
VERSION = '1.0
|
| 88 |
|
| 89 |
config = configFile()
|
| 90 |
with open(config['config-path'], "w") as outfile:
|
|
|
|
| 84 |
def getBMFull(): return osuApi.getFull(request)
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|
| 87 |
+
VERSION = '1.0 build77'
|
| 88 |
|
| 89 |
config = configFile()
|
| 90 |
with open(config['config-path'], "w") as outfile:
|
routes/witaiApi/recognizeVoice.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import wget
|
| 2 |
import random
|
| 3 |
import string
|
|
|
|
| 4 |
from .. import helpers
|
| 5 |
|
| 6 |
def recognizeVoice(request):
|
|
@@ -26,15 +27,22 @@ def recognizeVoice(request):
|
|
| 26 |
if fileExt == ".wav": fileHeader = {'Content-Type': 'audio/wav'}
|
| 27 |
elif fileExt == ".mp3": fileHeader = {'Content-Type': 'audio/mpeg3'}
|
| 28 |
elif fileExt == ".ogg": fileHeader = {'Content-Type': 'audio/ogg'}
|
|
|
|
| 29 |
else: return {"status": "error", "details": { "error_code": 111, "error_details": "Wrong file format (only ogg, wav, mp3)" }}
|
| 30 |
-
wget.download(url, f"
|
| 31 |
noEx = True
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
except Exception as e:
|
| 35 |
noEx = False
|
| 36 |
resp = e
|
| 37 |
-
helpers.deleteAudio(f"temp/{fileId}{fileExt}")
|
| 38 |
try:
|
| 39 |
if resp['text'] == "": return {"status": "pass", "result": "", "details": ""}
|
| 40 |
except: pass
|
|
|
|
| 1 |
import wget
|
| 2 |
import random
|
| 3 |
import string
|
| 4 |
+
import ffmpeg
|
| 5 |
from .. import helpers
|
| 6 |
|
| 7 |
def recognizeVoice(request):
|
|
|
|
| 27 |
if fileExt == ".wav": fileHeader = {'Content-Type': 'audio/wav'}
|
| 28 |
elif fileExt == ".mp3": fileHeader = {'Content-Type': 'audio/mpeg3'}
|
| 29 |
elif fileExt == ".ogg": fileHeader = {'Content-Type': 'audio/ogg'}
|
| 30 |
+
elif fileExt == '.aac': fileHeader = {'Content-Type': 'audio/wav'}
|
| 31 |
else: return {"status": "error", "details": { "error_code": 111, "error_details": "Wrong file format (only ogg, wav, mp3)" }}
|
| 32 |
+
wget.download(url, f"{config['temp-path']}/{fileId}{fileExt}")
|
| 33 |
noEx = True
|
| 34 |
+
if fileExt == ".aac":
|
| 35 |
+
audio_input = ffmpeg.input(f"{config['temp-path']}/{fileId}{fileExt}")
|
| 36 |
+
fileExt = ".wav"
|
| 37 |
+
audio_output = ffmpeg.output(audio_input.audio, f"{config['temp-path']}/{fileId}{fileExt}")
|
| 38 |
+
ffmpeg.run(audio_output)
|
| 39 |
+
helpers.deleteAudio(f"{config['temp-path']}/{fileId}.aac")
|
| 40 |
+
with open(f"{config['temp-path']}/{fileId}{fileExt}", 'rb') as f:
|
| 41 |
+
try: resp = helpers.dictation("ANR3UUMGUHZJFF366EY3YM3FS54QDJPF", f, fileHeader)
|
| 42 |
except Exception as e:
|
| 43 |
noEx = False
|
| 44 |
resp = e
|
| 45 |
+
helpers.deleteAudio(f"{config['temp-path']}/{fileId}{fileExt}")
|
| 46 |
try:
|
| 47 |
if resp['text'] == "": return {"status": "pass", "result": "", "details": ""}
|
| 48 |
except: pass
|