Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,25 +37,11 @@ nlp = spacy.load("en_core_web_sm")
|
|
| 37 |
|
| 38 |
def process_audio(audio_file):
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
# 使用 DeepSeek 生成回應(如果成功加載模型)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
# 修正後:將這個判斷放在函數內部,並且去掉多餘的縮進
|
| 57 |
-
|
| 58 |
-
if deepseek_pipe is not None:
|
| 59 |
messages=[{"role": "user", "content": result}]
|
| 60 |
deepseek_response=deepseek_pipe(messages)[0]["generated_text"]
|
| 61 |
|
|
@@ -77,8 +63,6 @@ def process_audio(audio_file):
|
|
| 77 |
# 可以添加預設回應或錯誤信息
|
| 78 |
|
| 79 |
}
|
| 80 |
-
|
| 81 |
-
|
| 82 |
|
| 83 |
with gr.Blocks() as app:
|
| 84 |
|
|
@@ -93,7 +77,6 @@ with gr.Blocks() as app:
|
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
-
|
| 97 |
|
| 98 |
|
| 99 |
|
|
|
|
| 37 |
|
| 38 |
def process_audio(audio_file):
|
| 39 |
|
| 40 |
+
# 語音轉文字
|
| 41 |
+
result = whisper_pipe(audio_file)["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
# 使用 DeepSeek 生成回應(如果成功加載模型)
|
| 44 |
+
if deepseek_pipe is not None:
|
|
|
|
|
|
|
|
|
|
| 45 |
messages=[{"role": "user", "content": result}]
|
| 46 |
deepseek_response=deepseek_pipe(messages)[0]["generated_text"]
|
| 47 |
|
|
|
|
| 63 |
# 可以添加預設回應或錯誤信息
|
| 64 |
|
| 65 |
}
|
|
|
|
|
|
|
| 66 |
|
| 67 |
with gr.Blocks() as app:
|
| 68 |
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
|