speech模块实现语音识别
生活随笔
收集整理的這篇文章主要介紹了
speech模块实现语音识别
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.pip安裝speech、pywin32
pip install speech pip install pywin322.例子
#!/usr/bin/python # coding:utf-8 from __future__ import unicode_literals import speech import os import sys import webbrowser__author__ = "klx" # Create your views here. phrase = {"closeMainSystem": "關(guān)閉","film": "電影","listenMusic": "好累","blog": "博客","cmd": "命令","baidu": "百度", }def callback(phr, phrase):if phr == phrase["closeMainSystem"]:speech.say("Goodbye. 人機(jī)交互即將關(guān)閉,謝謝使用")speech.stoplistening()sys.exit()elif phr == phrase["film"]:speech.say("正在為您打開(kāi)優(yōu)酷")webbrowser.open_new("http://www.youku.com/")elif phr == phrase["listenMusic"]:speech.say("即將為你啟動(dòng)豆瓣電臺(tái)")webbrowser.open_new("http://douban.fm/")elif phr == phrase["blog"]:speech.say("即將進(jìn)入Dreamforce.me")webbrowser.open_new("http://www.cnblogs.com/darksouls/")elif phr == phrase["cmd"]:speech.say("即將打開(kāi)CMD")os.popen("C:\Windows\System32\cmd.exe")elif phr == phrase["baidu"]:speech.say("百度一下")webbrowser.open_new("http://www.baidu.com/")else:speech.say("say again")webbrowser.open_new("http://www.baidu.com/s?wd=" + phr)def main():while True:phr = speech.input()speech.say("You said %s" % phr)callback(phr, phrase)def test(request):main()?
ps:
pywin32模塊實(shí)現(xiàn)com(組件對(duì)象模型),實(shí)現(xiàn)不同應(yīng)用程序或者不同語(yǔ)言之間的二進(jìn)制通訊標(biāo)準(zhǔn)
轉(zhuǎn)載于:https://www.cnblogs.com/konglingxi/p/10217629.html
總結(jié)
以上是生活随笔為你收集整理的speech模块实现语音识别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: “RuntimeWarning: ove
- 下一篇: 【TensorFlow】——expand