phuntshowangdi
commited on
Commit
•
2330d2b
1
Parent(s):
0fd1932
Update app.py
Browse files
app.py
CHANGED
@@ -32,11 +32,14 @@ def transcribe_audio(audio_file):
|
|
32 |
# Read the content of the uploaded file
|
33 |
audio_content = audio_file.read()
|
34 |
|
35 |
-
#
|
36 |
-
waveform, sample_rate = torchaudio.load(BytesIO(audio_content)
|
37 |
-
waveform = waveform.mean(dim=0, keepdim=True) # Downmix stereo to mono
|
38 |
|
39 |
-
# Convert
|
|
|
|
|
|
|
|
|
40 |
waveform_np = waveform.numpy()
|
41 |
|
42 |
# Transcribe the audio
|
|
|
32 |
# Read the content of the uploaded file
|
33 |
audio_content = audio_file.read()
|
34 |
|
35 |
+
# Load the audio using torchaudio.load
|
36 |
+
waveform, sample_rate = torchaudio.load(BytesIO(audio_content))
|
|
|
37 |
|
38 |
+
# Convert to mono if stereo
|
39 |
+
if waveform.shape[0] > 1:
|
40 |
+
waveform = torch.mean(waveform, dim=0, keepdim=True)
|
41 |
+
|
42 |
+
# Convert the waveform to numpy array
|
43 |
waveform_np = waveform.numpy()
|
44 |
|
45 |
# Transcribe the audio
|