Spaces:
Runtime error
Runtime error
change format to wav
Browse files- nemo_asr.py +7 -5
nemo_asr.py
CHANGED
@@ -3,6 +3,7 @@ import nemo
|
|
3 |
import nemo.collections.asr as nemo_asr
|
4 |
import librosa
|
5 |
import soundfile as sf
|
|
|
6 |
|
7 |
|
8 |
def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
@@ -23,8 +24,9 @@ def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
|
23 |
# for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
|
24 |
# print(f"Audio in {fname} was recognized as: {transcription}")
|
25 |
# print(transcription[0])
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
3 |
import nemo.collections.asr as nemo_asr
|
4 |
import librosa
|
5 |
import soundfile as sf
|
6 |
+
from pydub import AudioSegment
|
7 |
|
8 |
|
9 |
def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
|
|
|
24 |
# for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
|
25 |
# print(f"Audio in {fname} was recognized as: {transcription}")
|
26 |
# print(transcription[0])
|
27 |
+
sound = AudioSegment.from_file(file.name)
|
28 |
+
sound.export("test.wav",format='wav')
|
29 |
+
x, sr = librosa.load('test.wav')
|
30 |
+
sf.write("Test2.wav", x, 16000)
|
31 |
+
transcription= asr_model.transcribe(["Test2.wav"])
|
32 |
+
return transcription[0]
|