1

我使用谷歌语音 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) 
    

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

4

0 回答 0