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))
相关推荐
GJGCY7 小时前
金融AI Agent厂商怎么选?系统集成、API/RPA、权限审计与异常恢复能力评估
人工智能·经验分享·ai·金融·智能体
D_C_tyu7 小时前
AI Vibe Coding | AI能力评估提示词参考
人工智能·提示词·vibe coding
IT_陈寒7 小时前
Python的列表推导式用不好真的会爆内存你知道吗
前端·人工智能·后端
ZhengEnCi7 小时前
vLLM是什么:PagedAttention 让大模型推理快 2-4 倍,还能撑起更长思维链
人工智能·性能优化·llm
注塑机数据采集联网7 小时前
注塑机生产管控MES系统应用
大数据·运维·服务器·人工智能·物联网
kyriewen7 小时前
我算了笔账:AI 编程工具一年烧掉两台 MacBook
前端·人工智能·程序员
云和数据.ChenGuang7 小时前
Python 常见特殊方法详解:__new__、__init__、__del__、__str__、__repr__ 与 __getattribute__
开发语言·人工智能·python·1024程序员节
一个简单的TTS开发者7 小时前
#有声小说多角色对话 TTS 配置与选型指南
人工智能·开源·indextts
没落之王7 小时前
历史系统建模:宋初太祖太宗「再立天庭」秩序重构推演
人工智能·算法·重构
海宇服务7 小时前
零信任架构实战:基于海宇全国车辆配置查验构建自动化二手商用车出厂参数建档网关
运维·人工智能·架构·自动化·1024程序员节