0

Im Working with pydub, and I'm using ffplay. For some reason, when the program runs i get this 'error':

 /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)

However, it still plays the selected audio file.

  1. Is there a way to make this warning disappear, as it happens every time i play it?
  2. If i can't, is there anyway i can configure this so that it uses pyaudio to play the stream?
John Doe
  • 126
  • 1
  • 3
  • 15

1 Answers1

0

It's a warning (and not an error) because it's possible that everything is fine, but that is not guaranteed.

The warning is displayed when you import pydub.playback (which, in retrospect wasn't the best place for it).

That said, you'll probably want to use pyaudio directly for all but the very simplest cases. Pydub's pyaudio playback code provides a starting point if you like (inlined below for posterity):

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()  
Jiaaro
  • 74,485
  • 42
  • 169
  • 190