rutsam commited on
Commit
e14a4f8
1 Parent(s): da923e2

fix typo in nemo

Browse files
Files changed (1) hide show
  1. nemo_asr.py +12 -12
nemo_asr.py CHANGED
@@ -5,18 +5,18 @@ import nemo.collections.asr as nemo_asr
5
 
6
  def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
7
  with aiofiles.open(file.filename, 'wb') as out_file:
8
- content = file.read() # async read
9
- out_file.write(content) # async write
10
  print(out_file.name)
11
- asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained(
12
  model_name=modelName)
13
- if not file.name.endswith("wav"):
14
- sound = AudioSegment.from_mp3(out_file.name)
15
- sound.export(out_file.name, format="wav")
16
- files = [out_file.name]
17
- pac.convert_wav_to_16bit_mono(out_file.name,out_file.name)
18
  # print("file loaded is **************",file.file)
19
- for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
20
- print(f"Audio in {fname} was recognized as: {transcription}")
21
- print(transcription[0])
22
- return {"text": transcription[0], "filename": file.filename}
 
5
 
6
  def transcribe(file, modelName="stt_rw_conformer_transducer_large"):
7
  with aiofiles.open(file.filename, 'wb') as out_file:
8
+ out_file = file.read() # async read
9
+ #out_file.write(content) # async write
10
  print(out_file.name)
11
+ asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained(
12
  model_name=modelName)
13
+ if not file.name.endswith("wav"):
14
+ sound = AudioSegment.from_mp3(out_file.name)
15
+ sound.export(out_file.name, format="wav")
16
+ files = [out_file.name]
17
+ pac.convert_wav_to_16bit_mono(out_file.name,out_file.name)
18
  # print("file loaded is **************",file.file)
19
+ for fname, transcription in zip(files, asr_model.transcribe(paths2audio_files=files)):
20
+ print(f"Audio in {fname} was recognized as: {transcription}")
21
+ print(transcription[0])
22
+ return {"text": transcription[0], "filename": file.filename}