python - Error generated in pyaudio stream assignment -
good day. new pyaudio. trying run following code, after cleaning errors , , launching jackd.
def generate_sample(self, ob, preview): print("* generating sample...") tone_out = array(ob, dtype=int16) if preview: print("* previewing audio file...") bytestream = tone_out.tobytes() pya = pyaudio.pyaudio() stream = pya.open(format=pya.get_format_from_width(width=2), channels=1, rate=output_sample_rate, output=true) stream.write(bytestream) stream.stop_stream() stream.close() pya.terminate() print("* preview completed!") else: write('sound.wav', sample_rate, tone_out) print("* wrote audio file!")
the line sets stream generates following error:
type error: unbound method get_format_from_width() must called pyaudio instance first argument ( got int instance...
all of coding sources have found use exact same function call , fail. not understand ( , others ) have done wrong. thank you. if matters, running python 2.7.9 on raspberry pi / raspbian.
Comments
Post a Comment