我正在使用pydub,我正在使用ffplay。出于某种原因,当程序运行时,我得到这个'错误':
/usr/local/lib/python2.7/site-packages/pydub/utils.py:178:
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)
但是,它仍会播放所选的音频文件。
答案 0 :(得分:0)
这是一个警告(而不是错误),因为可能一切都很好,但不能保证。
导入pydub.playback
时会显示警告(回想起来,它不是最适合的地方)。
那就是说,除了最简单的情况之外,你可能想直接使用pyaudio。如果你愿意的话,Pydub的pyaudio playback code提供了一个起点(下面为后人内联):
def play_with_pyaudio(seg):
"""
seg should be a pydub.AudioSegment instance
"""
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=p.get_format_from_width(seg.sample_width),
channels=seg.channels,
rate=seg.frame_rate,
output=True)
# break audio into half-second chunks (to allows keyboard interrupts)
for chunk in make_chunks(seg, 500):
stream.write(chunk._data)
stream.stop_stream()
stream.close()
p.terminate()