i making a program that plays a video when it matches with a word that a person says, if it matches, the video shows in a tkinter label.My problem is when it matches more than one word, because the program plays all the videos that matches at once.I want to play all the videos that matches with the words one after another.Im using tkinter and tkvideo . Hope you can help me with this one.
dir = 'C:\\Users\\Usuario\\Desktop\\Prototipo\\palabras'listaVid = []with os.scandir(dir) as ficheros: for fichero in ficheros: listaVid.append(fichero.name.replace('.mp4',''))def audioTexto(): listener = sr.Recognizer() with sr.Microphone(device_index=0) as source: print("Escuchando...") audio = listener.listen(source) rec = listener.recognize_whisper(audio, language="spanish") trans_tab = dict.fromkeys(map(ord, u'\u0301\u0308'), None) rec = normalize('NFKC', normalize('NFKD', rec).translate(trans_tab)) rec = re.sub(r'[.]', '', rec) palabras = rec.split(',') try: for palabra in palabras: for vid in listaVid: if vid in palabra: player = tkvideo.tkvideo('C:\\Users\\Usuario\\Desktop\\Reconocimiento de voz\\palabras\\'+vid+'.mp4', lblVid,loop=0, size = (640,360)) player.play() except sr.UnknownValueError: print("No se entiende") except sr.RequestError as e: print("error")root =Tk()btnHablar = Button(root,text='Hablar..',command= audioTexto)btnHablar.grid(column=0, row=0 , padx=5 ,pady=5)lblVid = Label(root)lblVid.grid(column=0,row=2,columnspan=2)root.mainloop()