#python #python-3.x
Вопрос:
from threading import *
import speech_recognition as sr
import requests
from gtts import gTTS
from playsound import playsound
from fpdf import FPDF
import os
import pyttsx3
class A(Thread):
def run(self):
while True:
print("Hello World")
engine.say("Welcome")
engine.runAndWait()
class B(Thread):
def run(self):
while True:
with sr.Microphone() as source:
print("Speak Anything")
audio=r.listen(source)
try:
message=r.recognize_google(audio)
print("You said : {}".format(message))
except:
print("Sorry Could not recognize your voice")
if __name__=="__main__":
engine=pyttsx3.init()
r=sr.Recognizer()
t1=A()
t2=B()
t1.start()
t2.start()
Когда я запускаю его,он печатает Hello World и напрямую просит Говорить что угодно, но я хочу, чтобы engine.say() должен быть выполнен, Что мне делать ?