import gradio as gr | |
def speech_to_text(audio): | |
# 这里暂时返回固定文本,后续可接入语音识别模型 | |
return "这是语音转文本的结果。" | |
demo = gr.Interface( | |
fn=speech_to_text, | |
inputs=gr.Audio(sources=["upload","microphone"], type="filepath"), | |
outputs="text", | |
title="语音转文本演示", | |
description="请录制一段语音,系统将返回转写文本(目前为默认文本)。" | |
) | |
demo.launch() | |