You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The playsound library encountered an issue when attempting to use the temporary file path in Windows, resulting in an error during playback.
File "C:\Users\user_name\AppData\Local\pypoetry\Cache\virtualenvs\llms-course-cecv-ynhqYloT-py3.10\lib\site-packages\playsound.py", line 72, in _playsoundWin
winCommand(u'open {}'.format(sound))
File "C:\Users\user_name\AppData\Local\pypoetry\Cache\virtualenvs\llms-course-cecv-ynhqYloT-py3.10\lib\site-packages\playsound.py", line 64, in winCommand
raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
Error 305 for command:
open "C:\Users\user_name\AppData\Local\Temp\PSelb4boc8.mp3"
Solution
An adjustment was made to the _playsoundWin function to correctly utilize the temporary file path. The modification involved using os.path.normpath to ensure the correct formatting of the temporary file path in Windows.
Code Modification
# Existing codedefwinCommand(*command):
bufLen=600buf=c_buffer(bufLen)
command=' '.join(command).encode('utf-16')
errorCode=int(windll.winmm.mciSendStringW(command, buf, bufLen-1, 0)) # use widestring version of the functioniferrorCode:
errorBuffer=c_buffer(bufLen)
windll.winmm.mciGetErrorStringW(errorCode, errorBuffer, bufLen-1) # use widestring version of the functionexceptionMessage= ('\n Error '+str(errorCode) +' for command:''\n '+command.decode('utf-16') +'\n '+errorBuffer.raw.decode('utf-16').rstrip('\0'))
logger.error(exceptionMessage)
raisePlaysoundException(exceptionMessage)
returnbuf.valueif'\\'insound:
sound='"'+sound+'"'# Modified code (added line to normalize the temporary file path)sound=os.path.normpath(sound)
This modification ensures that the temporary file path is correctly formatted for Windows, allowing playsound to utilize the temporary file without encountering errors.
Steps to Reproduce
Use the playsound library on Windows.
Attempt to play an audio file using a temporary file path.
Observe the error encountered due to incorrect formatting of the temporary file path.
Expected Behavior
The playsound library should be able to utilize the temporary file path correctly on Windows and play the audio file without errors.
The text was updated successfully, but these errors were encountered:
Issue Description
Problem
The
playsound
library encountered an issue when attempting to use the temporary file path in Windows, resulting in an error during playback.Solution
An adjustment was made to the
_playsoundWin
function to correctly utilize the temporary file path. The modification involved usingos.path.normpath
to ensure the correct formatting of the temporary file path in Windows.Code Modification
This modification ensures that the temporary file path is correctly formatted for Windows, allowing
playsound
to utilize the temporary file without encountering errors.Steps to Reproduce
playsound
library on Windows.Expected Behavior
The
playsound
library should be able to utilize the temporary file path correctly on Windows and play the audio file without errors.The text was updated successfully, but these errors were encountered: