我正在尝试将 pydub 用于音乐项目,但是在尝试使用这段代码播放声音时
from pydub import AudioSegment
from pydub.playback import play
sound = AudioSegment.from_wav("s1.wav")
play(sound)
我收到以下错误:
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Python\Python385\lib\site-packages\pydub\utils.py:184: RuntimeWarning: Couldn't find ffplay or avplay - defaulting to ffplay, but may not work
warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:/Users/vicen/Desktop/music project/mian.py", line 6, in <module>
play(s1)
File "C:\Python\Python385\lib\site-packages\pydub\playback.py", line 74, in play
_play_with_ffplay(audio_segment)
File "C:\Python\Python385\lib\site-packages\pydub\playback.py", line 18, in _play_with_ffplay
seg.export(f.name, "wav")
File "C:\Python\Python385\lib\site-packages\pydub\audio_segment.py", line 809, in export
out_f, _ = _fd_or_path_or_tempfile(out_f, 'wb+')
File "C:\Python\Python385\lib\site-packages\pydub\utils.py", line 60, in _fd_or_path_or_tempfile
fd = open(fd, mode=mode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\vicen\\AppData\\Local\\Temp\\tmpvwotqts5.wav'
有人明白为什么它不起作用吗?我对python相当陌生,所以我不知道。