0

I was trying to code a voice assistant with the help of an online tutorial. When I tried to run the code, I kept kept getting an error message saying:

Error 263 for command:
        close voice.mp3
    The specified device is not open or is not recognized by MCI.
Failed to close the file: voice.mp3

*Note: "voice.mp3" is the name I gave to the mp3 file.

This is the only function in the program which used "voice.mp3", as well as the Playsound module:

def speak(text):
    tts = gTTS(text=text, tld="ca", lang="en")
    filename = "voice.mp3"
    tts.save(filename)
    playsound.playsound(filename)

I believe it has something to do with Playsound. Does anyone know how to fix this?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • Did you forget to show your code? –  Dec 03 '21 at 08:18
  • See this link https://stackoverflow.com/questions/68826091/the-specified-device-is-not-open-or-is-not-recognized-by-mci , may can help you – abdou_dev Dec 03 '21 at 13:18
  • 1
    Does this answer your question? [The specified device is not open or is not recognized by MCI](https://stackoverflow.com/questions/68826091/the-specified-device-is-not-open-or-is-not-recognized-by-mci) – Tomerikoo Dec 05 '21 at 09:40
  • 1
    @abdou_dev If you think this question has an answer somewhere else in this site - [flag it as duplicate](https://stackoverflow.com/help/privileges/flag-posts) instead of just posting a link... – Tomerikoo Dec 05 '21 at 09:42

1 Answers1

1

I just added ./ to the name of the file in the code.

filename = "./voice.mp3"
Anurag A S
  • 725
  • 10
  • 23
Araujodkk
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 14 '22 at 15:43
  • It works. But it's a strange behavior and should be documented. – Zbyszek Aug 31 '23 at 05:46