Update app.py
Browse files
app.py
CHANGED
@@ -67,6 +67,9 @@ AUDIO_LEN = 1.0
|
|
67 |
|
68 |
def load_audio(filename):
|
69 |
waveform, sr = torchaudio.load(filename)
|
|
|
|
|
|
|
70 |
audio_info = 'Original input audio length {:.2f} seconds, number of channels: {:d}, sampling rate: {:d}.'.format(waveform.shape[1]/sr, waveform.shape[0], sr)
|
71 |
waveform = waveform - waveform.mean()
|
72 |
fbank = torchaudio.compliance.kaldi.fbank(waveform, htk_compat=True, sample_frequency=sr,
|
|
|
67 |
|
68 |
def load_audio(filename):
|
69 |
waveform, sr = torchaudio.load(filename)
|
70 |
+
if sr != 16000:
|
71 |
+
waveform = torchaudio.functional.resample(waveform=waveform, orig_freq=sr, new_freq=16000)
|
72 |
+
sr = 16000
|
73 |
audio_info = 'Original input audio length {:.2f} seconds, number of channels: {:d}, sampling rate: {:d}.'.format(waveform.shape[1]/sr, waveform.shape[0], sr)
|
74 |
waveform = waveform - waveform.mean()
|
75 |
fbank = torchaudio.compliance.kaldi.fbank(waveform, htk_compat=True, sample_frequency=sr,
|