когда выполняю RunAndWait то все встает.
def Speak(what):
print(what)
speak_engine.say(what)
print("run and wait будет выполняться")
speak_engine.runAndWait()
print("run and wait вып")
speak_engine.stop()
def Callback(recognizer, audio):
try:
voice = recognizer.recognize_google(audio, language="ru")
print("[Чат] Ты: " + voice)
if not IsCallToBot(voice, name):
print("Not to bot")
return
comands = GetCmdsInStr(voice, cmds)
if comands == "null":
print(f"[Чат] {GetRName(name).capitalize()}: ", end= "")
Speak("Не понял ни одной команды")
return
ExecuteComands(comands)
except:
pass
speak_engine = pyttsx3.init()
with micro as audio:
reco.adjust_for_ambient_noise(audio)
Speak("День добрый")
stop_listening = reco.listen_in_background(micro, Callback)
while True: time.sleep(0.1)
ну в результате получаем что при вызове Speak из Callback все зависает на run and wait. Вот консоль:
День добрый
run and wait будет выполняться
run and wait вып
[Чат] Ты: Кеша
[Чат] Иннокентий: Не понял ни одной команды
run and wait будет выполняться