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))
相关推荐
YangYang9YangYan7 小时前
2027供应链计划校招:数学与应用数学专业如何把预测模型讲成业务决策?
人工智能·sql·算法
jsjzsl27 小时前
递归自改进系统(RSI)的本质是自发对称破缺:智能爆炸有界—— AI研发切记盲目投入
人工智能·python·算法
天远数科7 小时前
零信任架构实战:基于天远贷前风险报告构建自动化消金信贷风控与多头共债排查网关
运维·人工智能·架构·自动化
冬奇Lab7 小时前
LLM 驱动的自动化测试系列(12):像素 diff 之外,谁真的在让 LLM「看懂」UI 变化
人工智能·测试
派小心.7 小时前
小程序分享链路中来源参数的传递校验
大数据·前端·数据库·人工智能·小程序·数据分析
2601_954811827 小时前
机器视觉教学套件选型指南:五维技术参数对比与课程体系评估
python·数码相机
AI创界者7 小时前
摆脱云端API限制!Index-Translate 本地化部署整合包与实战:6GB显存畅跑150种语言,支持超长文本、字幕与API调用
人工智能·aigc
小马不起床7 小时前
零基础玩转 FastAPI_05:后端课程模块
python·fastapi
杨杨杨大侠8 小时前
Agent 的上下文和记忆怎么管?从 Harness 到 AgentScope 实现
人工智能·agent