Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,6 +79,9 @@ def run_asr_ctc(input_audio: str, target_language: str) -> str:
|
|
| 79 |
# Ensure shape [B x T]
|
| 80 |
if len(audio_tensor.shape) == 1:
|
| 81 |
audio_tensor = audio_tensor.unsqueeze(0) # Add batch dimension if missing
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Resample to 16kHz
|
| 84 |
audio_tensor = torchaudio.functional.resample(audio_tensor, orig_freq=orig_freq, new_freq=16000)
|
|
@@ -114,6 +117,9 @@ def run_asr_rnnt(input_audio: str, target_language: str) -> str:
|
|
| 114 |
# Ensure shape [B x T]
|
| 115 |
if len(audio_tensor.shape) == 1:
|
| 116 |
audio_tensor = audio_tensor.unsqueeze(0) # Add batch dimension if missing
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
# Resample to 16kHz
|
| 119 |
audio_tensor = torchaudio.functional.resample(audio_tensor, orig_freq=orig_freq, new_freq=16000)
|
|
|
|
| 79 |
# Ensure shape [B x T]
|
| 80 |
if len(audio_tensor.shape) == 1:
|
| 81 |
audio_tensor = audio_tensor.unsqueeze(0) # Add batch dimension if missing
|
| 82 |
+
|
| 83 |
+
if audio_tensor.ndim > 1:
|
| 84 |
+
audio_tensor = audio_tensor.squeeze(0)
|
| 85 |
|
| 86 |
# Resample to 16kHz
|
| 87 |
audio_tensor = torchaudio.functional.resample(audio_tensor, orig_freq=orig_freq, new_freq=16000)
|
|
|
|
| 117 |
# Ensure shape [B x T]
|
| 118 |
if len(audio_tensor.shape) == 1:
|
| 119 |
audio_tensor = audio_tensor.unsqueeze(0) # Add batch dimension if missing
|
| 120 |
+
|
| 121 |
+
if audio_tensor.ndim > 1:
|
| 122 |
+
audio_tensor = audio_tensor.squeeze(0)
|
| 123 |
|
| 124 |
# Resample to 16kHz
|
| 125 |
audio_tensor = torchaudio.functional.resample(audio_tensor, orig_freq=orig_freq, new_freq=16000)
|