Python:当用户单击停止按钮时停止Google音频录制

问题描述

我正在使用Google Speech API

系统应按以下方式工作:

1-当用户单击“开始”按钮时,系统应开始记录

2-当用户单击“停止”按钮时,系统将停止记录并显示结果

她是我的“开始”按钮定义

def Recite():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        audio = r.listen(source)
        try:
            global s
            s = r.recognize_google(audio,language ="ar-AR")

        except sr.UnkNownValueError: 
            print("Google Speech Recognition Could not understand audio") 
            title4= tk.Label(text ="غير مفهوم ",foreground="red")
            title4.grid(column=0,row=16)
        except sr.RequestError as e: 
            print("Could not request results from Google Speech Recognition service; {0}".format(e))
            title5= tk.Label(text ="حدث خطأ ",foreground="red")
            title5.grid(column=0,row=16) 
    

我的问题是,当用户要停止录制并单击“停止”按钮时,如何调用一个定义?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)