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))
相关推荐
播播资源7 小时前
同账户实测 11 个多模态模型:图像 0.03 元起、竖屏视频 8 元一条,最贵和最便宜差 267 倍
大数据·人工智能·深度学习
Linye7 小时前
AI 越跑越偏?从 500 行臃肿规则到 80 行核心约束:多 Agent 项目中的「规则瘦身与防腐」四步排查法
人工智能·架构
Eyfcom7 小时前
〖AI物流落地 06〗AI Copilot 在 TMS 调度系统中的应用:Text-to-SQL、意图拆解与自动调参
人工智能·物流系统·快递系统·跨境物流快递系统·ai物流落地
域限奇点访客7 小时前
怎么让AI稳定输出可解析的问卷结构?schema约束、失败重试与降级策略
人工智能
探索前端7 小时前
把带贴图的 OBJ / glTF 转成 3D Tiles:我写了个 mesh-to-tiles
人工智能
nicksxs7 小时前
把 LLM 判断拆成 Choice / Score / Noul:Jev SDK 六条实测
人工智能
happylifetree7 小时前
Python79:核心语法-面向对象基础-实例方法
python
AICoder码农王7 小时前
AgentScope Java v2 Lab-1,审批只走有门的腿
人工智能
AI前端工程狮7 小时前
1 秒超时,3 秒才写完:MCP 写操作的重复提交实测
人工智能·程序员