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))
相关推荐
屿华AI8 分钟前
AUTOSAR 实战-诊断工具 | UDS 0x27 安全访问的配置化实现:种子密钥算法插件化设计
python·测试工具·汽车
RobinDevNotes14 分钟前
Claude Code 剪视频,不上传、不要 API Key
人工智能·python·音视频·开发工具·ipython
stormzhangV28 分钟前
Coding Agent,通往 AGI 的重要一环
人工智能·agent·ai编程
Bowen_J2 小时前
Apple Foundation Models:Apple AI核心框架
人工智能·ai编程·apple
如夏倾城2 小时前
VRRP(虚拟路由器冗余协议Virtual Router Redundancy Protocol)
网络·python·网络协议·安全·智能路由器·负载均衡·信息与通信
IT_陈寒2 小时前
Redis那个过期删除策略,差点让我线上崩了
前端·人工智能·后端
IvanCodes2 小时前
LangChain(04):Runnable 与 LCEL 的执行与组合机制
python·langchain·agent
阿里云大数据AI技术2 小时前
AI 原生大数据服务 ADA 快速入门:完成首次对话式数据分析
大数据·人工智能
特创数字科技2 小时前
纯本地离线运行的文档脱敏工具(技术分享)
前端·驱动开发·python
字节跳动开源2 小时前
小红书/抖音图文排版利器——一个杂志风skill
人工智能·开源·设计