'voice assistant function problem in python

I am making a voice assistant in python, but a function related to an os module does not continue to listen after it runs and continues to listen after the window opened with the os module is closed, how can I solve this?

if "sistem ayarlarını aç" in voice: speak("açıyorum") os.system("msconfig.exe") if "merhaba" in voice: selection = ["sana da merhaba" , "merhaba" , "selam"] selection = random.choice(selection) speak(selection) There are codes like "os.system" doesn't keep listening after it works? r = sr.Recognizer() def record(ask = False): with sr.Microphone() as source: if ask: speak(ask) audio = r.listen(source) voice = '' try: voice = r.recognize_google(audio , language='tr-TR') except sr.UnknownValueError: time.sleep(10) selection = ["anlamadım" , "efendim" ] selection = random.choice(selection) print(selection) except sr.RequestError: speak('sistem çalışmıyor') return voice



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source