speech模块实现语音识别
生活随笔
收集整理的這篇文章主要介紹了
speech模块实现语音识别
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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": "關閉","film": "電影","listenMusic": "好累","blog": "博客","cmd": "命令","baidu": "百度", }def callback(phr, phrase):if phr == phrase["closeMainSystem"]:speech.say("Goodbye. 人機交互即將關閉,謝謝使用")speech.stoplistening()sys.exit()elif phr == phrase["film"]:speech.say("正在為您打開優酷")webbrowser.open_new("http://www.youku.com/")elif phr == phrase["listenMusic"]:speech.say("即將為你啟動豆瓣電臺")webbrowser.open_new("http://douban.fm/")elif phr == phrase["blog"]:speech.say("即將進入Dreamforce.me")webbrowser.open_new("http://www.cnblogs.com/darksouls/")elif phr == phrase["cmd"]:speech.say("即將打開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模塊實現com(組件對象模型),實現不同應用程序或者不同語言之間的二進制通訊標準
轉載于:https://www.cnblogs.com/konglingxi/p/10217629.html
總結
以上是生活随笔為你收集整理的speech模块实现语音识别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: “RuntimeWarning: ove
- 下一篇: 【TensorFlow】——expand