Update app.py
Browse files
app.py
CHANGED
|
@@ -101,6 +101,9 @@ def transcribe_core(path, model):
|
|
| 101 |
# 💬 主流程
|
| 102 |
# ========================
|
| 103 |
def transcribe_with_password(session_id, password, file, model_choice):
|
|
|
|
|
|
|
|
|
|
| 104 |
locked_flag, msg = check_lock(session_id)
|
| 105 |
if locked_flag:
|
| 106 |
return msg, "", ""
|
|
@@ -113,6 +116,7 @@ def transcribe_with_password(session_id, password, file, model_choice):
|
|
| 113 |
full, summ = transcribe_core(file, model_choice)
|
| 114 |
return "✅ 轉錄完成", full, summ
|
| 115 |
|
|
|
|
| 116 |
def ask_about_transcript(full_text, q):
|
| 117 |
if not full_text.strip():
|
| 118 |
return "⚠️ 尚未有轉錄內容"
|
|
@@ -127,13 +131,23 @@ def ask_about_transcript(full_text, q):
|
|
| 127 |
# 🌐 Gradio 介面
|
| 128 |
# ========================
|
| 129 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 130 |
-
gr.Markdown("## 🎧 語音轉錄與摘要工具(
|
| 131 |
|
| 132 |
session_state = gr.State(value=None)
|
| 133 |
|
| 134 |
with gr.Row():
|
| 135 |
-
password_input = gr.Textbox(
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
audio_input = gr.Audio(type="filepath", label="上傳音訊 (.m4a, .aac, .wav)")
|
| 139 |
transcribe_btn = gr.Button("開始轉錄與摘要 🚀")
|
|
|
|
| 101 |
# 💬 主流程
|
| 102 |
# ========================
|
| 103 |
def transcribe_with_password(session_id, password, file, model_choice):
|
| 104 |
+
# 修正注音輸入造成的隱藏字元錯誤
|
| 105 |
+
password = password.strip().replace(" ", "").replace("\u200b", "")
|
| 106 |
+
|
| 107 |
locked_flag, msg = check_lock(session_id)
|
| 108 |
if locked_flag:
|
| 109 |
return msg, "", ""
|
|
|
|
| 116 |
full, summ = transcribe_core(file, model_choice)
|
| 117 |
return "✅ 轉錄完成", full, summ
|
| 118 |
|
| 119 |
+
|
| 120 |
def ask_about_transcript(full_text, q):
|
| 121 |
if not full_text.strip():
|
| 122 |
return "⚠️ 尚未有轉錄內容"
|
|
|
|
| 131 |
# 🌐 Gradio 介面
|
| 132 |
# ========================
|
| 133 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 134 |
+
gr.Markdown("## 🎧 語音轉錄與摘要工具(私人API勿轉傳)")
|
| 135 |
|
| 136 |
session_state = gr.State(value=None)
|
| 137 |
|
| 138 |
with gr.Row():
|
| 139 |
+
password_input = gr.Textbox(
|
| 140 |
+
label="輸入密碼",
|
| 141 |
+
placeholder="請輸入英文與數字(請切換成英文輸入法)",
|
| 142 |
+
type="password",
|
| 143 |
+
max_lines=1
|
| 144 |
+
)
|
| 145 |
+
model_choice = gr.Dropdown(
|
| 146 |
+
["whisper-1", "gpt-4o-mini-transcribe"],
|
| 147 |
+
value="whisper-1",
|
| 148 |
+
label="選擇模型"
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
|
| 152 |
audio_input = gr.Audio(type="filepath", label="上傳音訊 (.m4a, .aac, .wav)")
|
| 153 |
transcribe_btn = gr.Button("開始轉錄與摘要 🚀")
|