rutsam commited on
Commit
d857f13
1 Parent(s): 5ca19d9

change format to wav

Browse files
Files changed (1) hide show
  1. 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
- x, sr = librosa.load(file.name)
27
- sf.write("Test.wav", x, 16000)
28
- transcription= asr_model.transcribe(["Test.wav"])
29
- print(transcription)
30
- return {"text": transcription, "filename": file.name}
 
 
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]