Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,6 +45,7 @@ with gr.Blocks(theme=gr.themes.Default(spacing_size="sm")) as app:
|
|
| 45 |
file_input = gr.File(
|
| 46 |
label="📁 Upload File (Text / Video / Audio)",
|
| 47 |
file_types=[".pdf", ".docx", ".txt", ".mp4", ".mov", ".wav", ".mp3", ".m4a"]
|
|
|
|
| 48 |
)
|
| 49 |
with gr.Column(scale=3):
|
| 50 |
text_input = gr.Textbox(
|
|
@@ -60,7 +61,7 @@ with gr.Blocks(theme=gr.themes.Default(spacing_size="sm")) as app:
|
|
| 60 |
# 输入优先级: 文件 > 文本
|
| 61 |
if file:
|
| 62 |
try:
|
| 63 |
-
|
| 64 |
except Exception as e:
|
| 65 |
return f"❌ File parsing failed: {str(e)}"
|
| 66 |
elif text.strip():
|
|
|
|
| 45 |
file_input = gr.File(
|
| 46 |
label="📁 Upload File (Text / Video / Audio)",
|
| 47 |
file_types=[".pdf", ".docx", ".txt", ".mp4", ".mov", ".wav", ".mp3", ".m4a"]
|
| 48 |
+
type="filepath" # ✅ 返回路径字符串,而不是 NamedString/File 对象
|
| 49 |
)
|
| 50 |
with gr.Column(scale=3):
|
| 51 |
text_input = gr.Textbox(
|
|
|
|
| 61 |
# 输入优先级: 文件 > 文本
|
| 62 |
if file:
|
| 63 |
try:
|
| 64 |
+
ctext, lang = extract_text(file) # ✅ 提取文本 + 自动识别语言
|
| 65 |
except Exception as e:
|
| 66 |
return f"❌ File parsing failed: {str(e)}"
|
| 67 |
elif text.strip():
|