Good day! I’ve created a desktop assistant that can play music for me through speech-recognition. This is my code:
while True: with sr.Microphone() as src: audio5 = recog1.listen(src, timeout=1, phrase_time_limit=5) # listens to what I will say(basically a song title) try: for files in os.listdir("C:\\Users\\Allexus\\Downloads"): # iterate in each file in Downloads folder if recog1.recognize_google(audio5, language="en-US") in files: # check if what i said above(which is "tonight") is found in the files in my Downloads folder print("Now playing " + os.path.basename(files)) # THIS WORKS PERFECTLY engine.say("Now playing " + os.path.basename(files)) # THIS WORKS PERFECTLY engine.runAndWait() # music = "im with you.mp3" files_type = os.path.splitext(files) if files_type == ".mp3": music = MP3(files) mixer.music.load(music) mixer.music.play() while mixer.music.get_busy(): time.Clock().tick(10)
but it’s giving me this error even though the .mp3 file exist in the directory:
raise MutagenError(e)mutagen.MutagenError: [Errno 2] No such file or directory: ‘tonight_3d.mp3.mp3’
If you need more info about anything please ask me and I will provide it. Thank you so much.