Spaces:
Running
on
Zero
Running
on
Zero
Ankush Rana
commited on
Commit
·
18b7be0
1
Parent(s):
ff06d12
resample with torchaudio
Browse files- whisper2.py +4 -3
whisper2.py
CHANGED
|
@@ -33,9 +33,9 @@ def change_formate(input_file):
|
|
| 33 |
|
| 34 |
|
| 35 |
def generate(audio):
|
| 36 |
-
audio = change_formate(audio)
|
| 37 |
input_audio, sample_rate = torchaudio.load(audio)
|
| 38 |
-
|
| 39 |
#metadata = torchaudio.info(audio)
|
| 40 |
#length1 = math.ceil(metadata.num_frames / metadata.sample_rate)
|
| 41 |
length = librosa.get_duration(path=audio)
|
|
@@ -109,4 +109,5 @@ def generate(audio):
|
|
| 109 |
if length <= 30:
|
| 110 |
return output[1:]
|
| 111 |
else:
|
| 112 |
-
return output[0]
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
def generate(audio):
|
| 36 |
+
# audio = change_formate(audio)
|
| 37 |
input_audio, sample_rate = torchaudio.load(audio)
|
| 38 |
+
input_audio = torchaudio.transforms.Resample(sample_rate, 16000)(input_audio)
|
| 39 |
#metadata = torchaudio.info(audio)
|
| 40 |
#length1 = math.ceil(metadata.num_frames / metadata.sample_rate)
|
| 41 |
length = librosa.get_duration(path=audio)
|
|
|
|
| 109 |
if length <= 30:
|
| 110 |
return output[1:]
|
| 111 |
else:
|
| 112 |
+
return output[0]
|
| 113 |
+
|