SeyedAli commited on
Commit
318958b
·
1 Parent(s): 6c67759

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -15,9 +15,13 @@ def ASR(audio):
15
  # Copy the contents of the uploaded audio file to the temporary file
16
  temp_audio_file.write(open(audio, "rb").read())
17
  temp_audio_file.flush()
18
- audio_array,sample_rate= torchaudio.load(temp_audio_file.name)
19
- inputs = processor(audio_array, sampling_rate=16_000)
20
- text = pipe(inputs=inputs.numpy())
 
 
 
 
21
  return text
22
  iface = gr.Interface(fn=ASR, inputs=audio_input, outputs="text")
23
  iface.launch(share=False)
 
15
  # Copy the contents of the uploaded audio file to the temporary file
16
  temp_audio_file.write(open(audio, "rb").read())
17
  temp_audio_file.flush()
18
+ # Load the audio file using torchaudio
19
+ waveform, sample_rate = torchaudio.load(temp_audio_file.name)
20
+
21
+ # Convert the PyTorch tensor to a NumPy ndarray
22
+ audio_array = waveform.numpy()
23
+ #inputs = processor(audio_array, sampling_rate=16_000)
24
+ text = pipe(audio_array)
25
  return text
26
  iface = gr.Interface(fn=ASR, inputs=audio_input, outputs="text")
27
  iface.launch(share=False)