Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,13 @@ def run_whisper(audio_path: str, target_language: str = None, is_translate: bool
|
|
| 33 |
return result["text"]
|
| 34 |
|
| 35 |
# 3. Gradio 交互逻辑
|
| 36 |
-
def gradio_predict(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
return run_whisper(audio_path, target_language=language, is_translate=is_translate)
|
| 38 |
|
| 39 |
# 4. 构建 Gradio 界面
|
|
|
|
| 33 |
return result["text"]
|
| 34 |
|
| 35 |
# 3. Gradio 交互逻辑
|
| 36 |
+
def gradio_predict(audio_input, language, is_translate):
|
| 37 |
+
# 自动兼容 API 传进来的各种格式(无论是字符串还是字典)
|
| 38 |
+
if isinstance(audio_input, dict):
|
| 39 |
+
audio_path = audio_input.get("path") or audio_input.get("name") or audio_input.get("url")
|
| 40 |
+
else:
|
| 41 |
+
audio_path = audio_input
|
| 42 |
+
|
| 43 |
return run_whisper(audio_path, target_language=language, is_translate=is_translate)
|
| 44 |
|
| 45 |
# 4. 构建 Gradio 界面
|