Spaces:
Runtime error
Runtime error
change audio to 16Khz
Browse files- nemo_asr.py +4 -1
- requirements.txt +0 -1
nemo_asr.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import aiofiles
|
| 2 |
import nemo
|
| 3 |
import nemo.collections.asr as nemo_asr
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
|
@@ -21,6 +22,8 @@ def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
|
| 21 |
# for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
|
| 22 |
# print(f"Audio in {fname} was recognized as: {transcription}")
|
| 23 |
# print(transcription[0])
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
print(transcription)
|
| 26 |
return {"text": transcription, "filename": file.name}
|
|
|
|
| 1 |
import aiofiles
|
| 2 |
import nemo
|
| 3 |
import nemo.collections.asr as nemo_asr
|
| 4 |
+
import librosa
|
| 5 |
|
| 6 |
|
| 7 |
def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
|
|
|
| 22 |
# for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
|
| 23 |
# print(f"Audio in {fname} was recognized as: {transcription}")
|
| 24 |
# print(transcription[0])
|
| 25 |
+
x, sr = librosa.load(file.name)
|
| 26 |
+
librosa.output.write_wav("Test.wav", x, sr=16000, norm=False)
|
| 27 |
+
transcription= asr_model.transcribe(["Test.wav"])
|
| 28 |
print(transcription)
|
| 29 |
return {"text": transcription, "filename": file.name}
|
requirements.txt
CHANGED
|
@@ -7,7 +7,6 @@ stt
|
|
| 7 |
webrtcvad
|
| 8 |
numpy
|
| 9 |
ffmpeg-python
|
| 10 |
-
librosa==0.9.1
|
| 11 |
soundfile==0.10.3.post1
|
| 12 |
wget
|
| 13 |
aiofiles
|
|
|
|
| 7 |
webrtcvad
|
| 8 |
numpy
|
| 9 |
ffmpeg-python
|
|
|
|
| 10 |
soundfile==0.10.3.post1
|
| 11 |
wget
|
| 12 |
aiofiles
|