Spaces:
Running
Running
Commit
·
fe027e3
1
Parent(s):
d7d7874
fix: enhance audio input handling in transcribe function
Browse files
app.py
CHANGED
|
@@ -24,6 +24,16 @@ def transcribe(audio, state=""):
|
|
| 24 |
if audio is None:
|
| 25 |
return state, state
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
global model
|
| 28 |
# Move model to GPU if available
|
| 29 |
if torch.cuda.is_available():
|
|
|
|
| 24 |
if audio is None:
|
| 25 |
return state, state
|
| 26 |
|
| 27 |
+
if isinstance(audio, tuple):
|
| 28 |
+
# If audio is a tuple, assume the first element is the file path
|
| 29 |
+
print("Received tuple input, extracting first element as file path")
|
| 30 |
+
audio = audio[0] if len(audio) > 0 else None
|
| 31 |
+
elif not isinstance(audio, str):
|
| 32 |
+
raise ValueError(f"Expected audio as a file path (str), got {type(audio)}")
|
| 33 |
+
|
| 34 |
+
if not audio:
|
| 35 |
+
raise ValueError("No valid audio input provided")
|
| 36 |
+
|
| 37 |
global model
|
| 38 |
# Move model to GPU if available
|
| 39 |
if torch.cuda.is_available():
|