Spaces:
Runtime error
Runtime error
File size: 1,435 Bytes
d83a28a 5b0b8b3 e2ba7c1 5b0b8b3 9bdde69 5b0b8b3 400f261 5b0b8b3 dd74287 400f261 dd74287 400f261 5b0b8b3 400f261 5b0b8b3 400f261 5b0b8b3 400f261 5b0b8b3 dd74287 400f261 d83a28a 400f261 5b0b8b3 400f261 5b0b8b3 d83a28a e2ba7c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import gradio as gr
from transformers import pipeline
# ✅ 使用Whisper大型模型(准确率最高)
asr = pipeline("automatic-speech-recognition", model="openai/whisper-large-v2")
# ✅ 使用中文T5摘要模型
summarizer = pipeline(
"text2text-generation",
model="IDEA-CCNL/Randeng-T5-1.3B-Summary-Chinese",
)
def process(audio_path, progress=gr.Progress()):
try:
progress(0, desc="🎧 正在识别中文语音...")
result = asr(audio_path)
text = result.get("text", "").strip()
except Exception as e:
return f"❌ 转写失败:{str(e)}"
if not text:
return "⚠️ 没有识别出文字,请确认音频清晰且为中文内容。"
progress(0.6, desc="🧠 正在生成中文摘要...")
try:
summary = summarizer(f"请总结以下中文内容:{text}", max_length=100, do_sample=False)[0]["generated_text"]
except Exception:
summary = "⚠️ 摘要生成失败,请稍后重试。"
progress(1.0, desc="✅ 完成!")
return f"🎧【转写结果】\n{text}\n\n🧠【摘要】\n{summary}"
demo = gr.Interface(
fn=process,
inputs=gr.Audio(type="filepath", label="上传中文面试录音(支持 mp3 / wav)"),
outputs="text",
title="🎙️ AI 中文面试复盘助手",
description="上传面试录音,自动中文转写 + 中文摘要。",
)
if __name__ == "__main__":
demo.launch()
|