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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -17,7 +17,12 @@ def ASR(audio):
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)
 
17
  temp_audio_file.flush()
18
  # Load the audio file using torchaudio
19
  waveform, sample_rate = torchaudio.load(temp_audio_file.name)
20
+ # Resample the audio to 16kHz
21
+ resampler = torchaudio.transforms.Resample(sample_rate, 16000)
22
+ waveform = resampler(waveform)
23
+ # Convert the audio to a single channel
24
+ downmix_mono = torchaudio.transforms.DownmixMono()
25
+ waveform = downmix_mono(waveform)
26
  # Convert the PyTorch tensor to a NumPy ndarray
27
  audio_array = waveform.numpy()
28
  #inputs = processor(audio_array, sampling_rate=16_000)