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))
相关推荐
笨笨聊运维19 分钟前
CentOS官方不维护版本,配置python升级方法,无损版
linux·python·centos
Gerardisite22 分钟前
如何在微信个人号开发中有效管理API接口?
java·开发语言·python·微信·php
小毛驴8501 小时前
软件设计模式-装饰器模式
python·设计模式·装饰器模式
serve the people1 小时前
机器学习(ML)和人工智能(AI)技术在WAF安防中的应用
人工智能·机器学习
闲人编程1 小时前
Python的导入系统:模块查找、加载和缓存机制
java·python·缓存·加载器·codecapsule·查找器
weixin_457760001 小时前
Python 数据结构
数据结构·windows·python
0***K8921 小时前
前端机器学习
人工智能·机器学习
陈天伟教授1 小时前
基于学习的人工智能(5)机器学习基本框架
人工智能·学习·机器学习
m0_650108242 小时前
PaLM-E:具身智能的多模态语言模型新范式
论文阅读·人工智能·机器人·具身智能·多模态大语言模型·palm-e·大模型驱动