Python 智能语音识别的功能

python 复制代码
import speech_recognition as sr

def voice_recognition():
    # 创建语音识别对象
    r = sr.Recognizer()
    # 从麦克风中获取音频
    with sr.Microphone() as source:
        print("Please speak...")
        audio = r.listen(source)
    try:
        # 使用 Google Speech Recognition API 进行识别
        text = r.recognize_google(audio, language='zh-CN')
        print("You said: ", text)
    except sr.UnknownValueError:
        print("Google Speech Recognition could not understand audio")
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))
相关推荐
长和信泰光伏储能20 小时前
探索未来能源:光伏储能技术解析
大数据·人工智能·能源
寻道码路20 小时前
LangChain4j Java AI 应用开发实战(二十六):多模型集成策略 —— OpenAI、DeepSeek、阿里百炼混合使用
java·开发语言·人工智能·ai
直接冲冲冲20 小时前
65-批量归一化
人工智能·深度学习·计算机视觉
树獭非懒20 小时前
六、Plan-and-Solve智能体:学会三思而后行
人工智能·llm·agent
武子康20 小时前
调查研究-214 OpenAI:Agent 不是更聪明的聊天框,而是新的工作组织方式
人工智能·openai·agent
火山引擎开发者社区20 小时前
告别手动翻资料:用 Agent Plan 搞定销售档案与问答
人工智能
鹰影4720 小时前
一款AI笔记助手和远程同步的markdown笔记idea-note
人工智能·笔记·rust·typescript·react
城事漫游Molly20 小时前
如何写出有说服力的研究论文Introduction——论证框架切入法
人工智能·论文写作·ai for science·博士生必读
行业研究员20 小时前
解决方案 | 腾讯云天御金融反电诈解决方案
人工智能·金融·腾讯云·金融反电诈·双模反诈
倔强的石头10620 小时前
让时间序列“开口说话”:TimechoAI 如何把工业数据变成安全可靠的智能洞察
人工智能