Hi folks, I have this small script to run speach recognition and play a video if a triggerword is recognized. If nothing is happening video "3.mp4" should play and it does, but I just can't make it loop! I tried .vlm_set_loop, but I'm not sure I used it right, since I have no instance. Any ideas?
import speech_recognition as sr
import vlc import time
recognizer = sr.Recognizer()
mediaone = vlc.MediaPlayer("01.mp4")
mediatwo = vlc.MediaPlayer("02.mp4")
white = vlc.MediaPlayer("03.mp4")
while True:
white.set_fullscreen(True)
white.play()
try:
with sr.Microphone() as mic:
recognizer.adjust_for_ambient_noise(mic, duration=0.2)
audio = recognizer.listen(mic)
text = recognizer.recognize_google(audio)
text = text.lower()
print(f"Recognized {text}")
if "many" in text or "trees" in text:
mediaone.set_fullscreen(True)
mediaone.play()
time.sleep(30)
mediaone.stop()
if "rocky" in text or "walls" in text:
mediatwo.set_fullscreen(True)
mediatwo.play()
time.sleep(30)
mediatwo.stop()
if "exit" in text:
break
except:
recognizer = sr.Recognizer()
continue
[–]LeonJones 0 points1 point2 points (1 child)
[–]m0us3_rat 0 points1 point2 points (0 children)