Open Zordon1337 opened 2 years ago
I'm getting a similar "Error 263 for command" error when trying to play a saved wav from a temp file. Error 263 for command: open "C:\Users\username\AppData\Local\Temp\tmpapvlu6_4" The specified device is not open or is not recognized by MCI.
and then I get an error trying to delete the temp file from my "finally" block: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\username\AppData\Local\Temp\tmpapvlu6_4'
I will update this comment as I debug and resolve this issue locally (if possible).
Glad to hear you’re trying to figure it out. I’m always annoyed by people who just report bugs and won’t recognize this is FOSS and that they should put some effort into fixing their own problems.
If you’re able to, remember to update the unit tests. I make sure those are passing on Mac and Windows before I accept any PRs (or make changes myself.)
Taylor
On Jul 4, 2022, at 02:32, AustinHellerRepo @.***> wrote:
I'm getting a similar "Error 263 for command" error when trying to play a saved wav from a temp file. Error 263 for command: open "C:\Users\username\AppData\Local\Temp\tmpapvlu6_4" The specified device is not open or is not recognized by MCI.
and then I get an error trying to delete the temp file from my "finally" block: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\username\AppData\Local\Temp\tmpapvlu6_4'
I will update this comment as I debug and resolve this issue locally (if possible).
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
I found a workaround for this. done = False while not done: try: playsound.playsound("C:\Users\username\AppData\PycharmProjects\trafficlights\light\audio.mp3") done = True except: continue This would make it that however many times error 263 comes up, it will try to do it again until it finally works(from my experience, sometimes it takes over 100 errors for this to finally play what i need it to play.
It’s interesting to hear that simply retrying 100 times makes it work.
It it’s just a matter of needing to delay, I’d be open to adding a small sleep statement, provided we can find a reasonable/appropriate amount of time to sleep for.
I’d really appreciate it if anybody could find a way to write a good unit test for reliably producing the issue in the current version so we could be sure that it’s actually fixed with whatever change…
On Jul 13, 2022, at 00:34, tigerjade003 @.***> wrote:
I found a workaround for this. done = False while not done: try: playsound.playsound("C:\Users\username\AppData\PycharmProjects\trafficlights\light") done = True except: continue This would make it that however many times error 263 comes up, it will try to do it again until it finally works(from my experience, sometimes it takes over 100 errors for this to finally play what i need it to play.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
With further testing, this sometimes causes a different error: Error 265 for command: open greenlight.mp3 The device name is already being used as an alias by this application. Use a unique alias.
With Even further testing, Another error comes up: Error 259 for command: play greenlight.mp3 wait The driver cannot recognize the specified command parameter.
Windows 10: Python 3.9.6. My Python project used playsound version 1.2.2, and worked perfectly. I then upgraded the package to version 1.3.0 and got the error
Error 263 for command:
open foreign_word.mp3
The specified device is not open or is not recognized by MCI.
Error 263 for command:
close foreign_word.mp3
The specified device is not open or is not recognized by MCI.
Failed to close the file: foreign_word.mp3
Traceback (most recent call last):
File "E:\Python\Projects\day-31_flash_cards\main.py", line 174, in <module>
display_card_front()
File "E:\Python\Projects\day-31_flash_cards\main.py", line 102, in display_card_front
playsound.playsound("foreign_word.mp3")
File "E:\Python\Projects\day-31_flash_cards\venv\lib\site-packages\playsound.py", line 72, in _playsoundWin
winCommand(u'open {}'.format(sound))
File "E:\Python\Projects\day-31_flash_cards\venv\lib\site-packages\playsound.py", line 64, in winCommand
raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
Error 263 for command:
open foreign_word.mp3
The specified device is not open or is not recognized by MCI.
I then reverted to version 1.2.2 using pip install playsound==1.2.2
, and everything worked perfectly again.
A different bug forced me back to pip install playsound==1.2.2
: Sound filenames containing dashes (-) raised an error.
import playsound#---------Used old version: pip install playsound==1.2.2
playsound.playsound('fifth-300.0-200.25.wav')
This fragment was used to test the full code under construction at
Because there hasn't been a lot of code been posted yet, the issue can be reproduced using the edge-tts library.
import asyncio
import tempfile
from playsound import playsound
import edge_tts
async def main():
"""
Main function
"""
communicate = edge_tts.Communicate()
with tempfile.NamedTemporaryFile() as temporary_file:
async for i in communicate.run("Hello World!"):
if i[2] is not None:
temporary_file.write(i[2])
playsound(temporary_file.name)
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
The SO thread might also be interesting: https://stackoverflow.com/questions/68826091/the-specified-device-is-not-open-or-is-not-recognized-by-mci
(Python 3.10.2, Windows 10)
going to pip install playsound==1.2.2 from version 1.3 resolved the issues I was having. Thanks for help.
Failed to close the file: ./music/cuagain.mp3 Traceback (most recent call last): File "C:\Users\Zordon\Desktop\NCS_PLAYER\main.py", line 12, in cuagain playsound('./music/cuagain.mp3') File "C:\Users\Zordon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 72, in _playsoundWin winCommand(u'open {}'.format(sound)) File "C:\Users\Zordon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 64, in winCommand raise PlaysoundException(exceptionMessage) playsound.PlaysoundException: Error 263 for command: open ./music/cuagain.mp3 The specified device is not open or is not recognized by MCI.