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))
相关推荐
冬奇Lab12 小时前
每日一个开源项目(第140篇):AgentScope 2.0 - 阿里开源的生产级 Agent 框架
人工智能·开源·agent
冬奇Lab12 小时前
Skill 系列(04):Skill 指标体系——L1/L2/L3 三层监控,让质量下降有据可查
人工智能·开源·llm
IT_陈寒13 小时前
Vite的静态资源打包让我熬夜到三点,这坑千万别跳
前端·人工智能·后端
玩转AI不是事14 小时前
用IndexedDB做AI对话离线缓存实战
人工智能
学测绘的小杨14 小时前
CompassFusion:一个从 GNSS 到 GNSS/INS 组合导航的独立工程包
python
Asize14 小时前
多模态生图:从 Vite 工程化到前端调用 Qwen Image
javascript·人工智能·后端
MobotStone14 小时前
AI项目越多,为什么越容易失控
人工智能·aigc
十有八七14 小时前
AI时代的置身X内
前端·人工智能
Lkstar15 小时前
A2A协议深度解析|Agent2Agent通信标准,智能体互联网的"HTTP"
人工智能·llm
百度Geek说15 小时前
当代码越来越便宜,什么在变贵?
人工智能