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))
相关推荐
eastyuxiao5 小时前
思维导图拆解项目范围 3 个真实落地案例
大数据·运维·人工智能·流程图
风落无尘6 小时前
《智能重生:从垃圾堆到AI工程师》——第五章 代码与灵魂
服务器·网络·人工智能
冬奇Lab6 小时前
RAG 系列(八):RAG 评估体系——用数据说话
人工智能·llm
landyjzlai7 小时前
蓝迪哥玩转Ai(8)---端侧AI:RK3588 端侧大语言模型(LLM)开发实战指南
人工智能·python
我叫黑大帅9 小时前
如何通过 Python 实现招聘平台自动投递
后端·python·面试
其实防守也摸鱼9 小时前
CTF密码学综合教学指南--第九章
开发语言·网络·python·安全·网络安全·密码学·ctf
ZhengEnCi9 小时前
05-自注意力机制详解 🧠
人工智能·pytorch·深度学习
砚底藏山河9 小时前
Python量化开发:2026最佳实时股票数据API接口推荐与对比
开发语言·windows·python