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))
相关推荐
一份汉堡套餐16 小时前
7月最新大模型排名
大数据·人工智能
山海云端有限公司16 小时前
实战指南:用豆包图片生成API快速搭建AI绘画能力
python·ai绘画·api调用·图片生成·豆包api
Figo_Cheung16 小时前
Figo整体‑集体思维下的人工智能时代社会治理体系研究——基于道家与儒家传统的系统性框架构建
人工智能
ganbingfenxiang16 小时前
山西干冰零售
大数据·人工智能·python·零售
薛定猫AI16 小时前
【深度解析】GLM-5.2 与 Z-Code:AI 编程智能体的原理拆解与 Python 调用实战
开发语言·人工智能·python
冰暮流星16 小时前
flask之定义URL
后端·python·flask
weixin_4000056016 小时前
RL-frenet-trajectory-planning-in-CARLA
人工智能·深度学习·算法·机器学习·自动驾驶
白白白飘16 小时前
【3】大语言模型的核心原理
人工智能·语言模型·自然语言处理
ZeekerLin17 小时前
AI时代,企业核心业务中台化建设思考
大数据·人工智能·企业ai转型
刘海东刘海东17 小时前
完成了一二三四章
人工智能