I'm newbie in Python and PysimpleGUI. I want to create a simple GUI for speech to text. Can Pysimple GUI make it? Or is there another GUI framework that can work other than PysimpleGUI? Now I have done creating the GUI but have some problem, I want to create a code for speak button to always get the voice and stop button when I want to stop get voice, but I don't know how to stop. When I test the program will freeze and I get the error:
>Traceback (most recent call last):
File "C:/Users/sumet3412/PycharmProjects/Speech2Txt/testPysimpleGUI.py", line 123, in <module>
value = r.recognize_google(audio, language="en-US")
File "C:\Users\sumet3412\PycharmProjects\Speech2Txt\venv\lib\site-packages\speech_recognition\__init__.py", line 672, in recognize_google
if "alternative" not in actual_result: raise UnknownValueError()
speech_recognition.UnknownValueError
import speech_recognition as sr
import PySimpleGUI as sg
r = sr.Recognizer()
m = sr.Microphone()
layout = [[sg.Text('Converter', font='Helvetica 15')],
[sg.ReadButton('Speak'), sg.ReadButton('Stop')],
[sg.Output(size=(80, 10))],
[sg.Exit()]]
window = sg.Window('Speech Recognition').Layout(layout)
while True:
event,values = window.Read()
if event is None or event == 'Exit':
break
elif event == 'Speak':
with m as source:
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
value = r.recognize_google(audio, language="en-US")
print(value)
window.Close()