Spaces:
Running
Running
Convert to mono
Browse files
app.py
CHANGED
@@ -25,6 +25,10 @@ def transcribe_audio(audio_file):
|
|
25 |
resampler = torchaudio.transforms.Resample(sample_rate, 16000)
|
26 |
audio = resampler(audio)
|
27 |
|
|
|
|
|
|
|
|
|
28 |
# Transcribe the audio
|
29 |
transcription = whisper_pipeline(audio.squeeze().numpy())["text"] # .squeeze() removes extra dimensions
|
30 |
|
|
|
25 |
resampler = torchaudio.transforms.Resample(sample_rate, 16000)
|
26 |
audio = resampler(audio)
|
27 |
|
28 |
+
# Convert to Mono
|
29 |
+
if audio.shape[0] > 1: # Check if multi-channel
|
30 |
+
audio = torch.mean(audio, dim=0, keepdim=True) # Average channels
|
31 |
+
|
32 |
# Transcribe the audio
|
33 |
transcription = whisper_pipeline(audio.squeeze().numpy())["text"] # .squeeze() removes extra dimensions
|
34 |
|