2
from playsound import playsound

playsound("1.mp3")

上面使用 playsound 模块的代码会导致以下错误。如何解决?

    Error 259 for command:
        play 1.mp3 wait
    The driver cannot recognize the specified command parameter.

    Error 263 for command:
        close 1.mp3
    The specified device is not open or is not recognized by MCI.
Failed to close the file: 1.mp3
Traceback (most recent call last):
  File "C:\Users\itsra\OneDrive\Desktop\Python\test.py", line 4, in <module>
    playsound("1.mp3")
  File "C:\Users\itsra\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 73, in _playsoundWin
    winCommand(u'play {}{}'.format(sound, ' wait' if block else ''))
  File "C:\Users\itsra\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 259 for command:
        play 1.mp3 wait
    The driver cannot recognize the specified command parameter.
4

2 回答 2

1

我也遇到了同样的问题。尝试降级 playsound 版本。利用

pip install playsound==1.2.2

这解决了它。

于 2021-10-05T06:07:37.450 回答
0

我也遇到了类似的问题。尝试转换成 wav 文件。它对我有用,我认为问题在于缺乏有关文件中音乐比特率的信息。在此处输入图像描述

于 2021-09-18T15:20:13.063 回答