九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
python實現(xiàn)語音控制
Speech Recognition may be possible with COM.
I found an example of how its done in Python.
from win32com.client import constantsimport win32com.clientimport pythoncom"""Sample code for using the Microsoft Speech SDK 5.1 via COM in Python.    Requires that the SDK be installed; it's a free download from            http://microsoft.com/speech    and that MakePy has been used on it (in PythonWin,    select Tools | COM MakePy Utility | Microsoft Speech Object Library 5.1).    After running this, then saying "One", "Two", "Three" or "Four" should    display "You said One" etc on the console. The recognition can be a bit    shaky at first until you've trained it (via the Speech entry in the Windows    Control Panel."""class SpeechRecognition:    """ Initialize the speech recognition with the passed in list of words """    def __init__(self, wordsToAdd):        # For text-to-speech        self.speaker = win32com.client.Dispatch("SAPI.SpVoice")        # For speech recognition - first create a listener        self.listener = win32com.client.Dispatch("SAPI.SpSharedRecognizer")        # Then a recognition context        self.context = self.listener.CreateRecoContext()        # which has an associated grammar        self.grammar = self.context.CreateGrammar()        # Do not allow free word recognition - only command and control        # recognizing the words in the grammar only        self.grammar.DictationSetState(0)        # Create a new rule for the grammar, that is top level (so it begins        # a recognition) and dynamic (ie we can change it at runtime)        self.wordsRule = self.grammar.Rules.Add("wordsRule",                        constants.SRATopLevel + constants.SRADynamic, 0)        # Clear the rule (not necessary first time, but if we're changing it        # dynamically then it's useful)        self.wordsRule.Clear()        # And go through the list of words, adding each to the rule        [ self.wordsRule.InitialState.AddWordTransition(None, word) for word in wordsToAdd ]        # Set the wordsRule to be active        self.grammar.Rules.Commit()        self.grammar.CmdSetRuleState("wordsRule", 1)        # Commit the changes to the grammar        self.grammar.Rules.Commit()        # And add an event handler that's called back when recognition occurs        self.eventHandler = ContextEvents(self.context)        # Announce we've started using speech synthesis        self.say("Started successfully")    """Speak a word or phrase"""    def say(self, phrase):        self.speaker.Speak(phrase)"""The callback class that handles the events raised by the speech object.    See "Automation | SpSharedRecoContext (Events)" in the MS Speech SDK    online help for documentation of the other events supported. """class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):    """Called when a word/phrase is successfully recognized  -        ie it is found in a currently open grammar with a sufficiently high        confidence"""    def OnRecognition(self, StreamNumber, StreamPosition, RecognitionType, Result):        newResult = win32com.client.Dispatch(Result)        print "You said: ",newResult.PhraseInfo.GetText()    if __name__=='__main__':    wordsToAdd = [ "One", "Two", "Three", "Four" , "boom"]    speechReco = SpeechRecognition(wordsToAdd)    while 1:        pythoncom.PumpWaitingMessages()

I didn't have the time to investigate how to translate it to ahk (if possible at all). Maybe someone else that has a good understanding of COM knows a little Python and has time can investigate this can make it work. Because i am busy with exploring WinSock2 with ahk at the moment.
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
python之語音識別(speech模塊)
Python入門
從第一步開始 教你用Python實現(xiàn)聊天機器人(基礎(chǔ)篇)
Python開發(fā)學(xué)習(xí)之Python用三十行代碼,打造一款簡單的人工語音對話
An Introduction to SAPI and Use of Speech In Applications
android
更多類似文章 >>
生活服務(wù)
熱點新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服