From: Paul Brossier Date: Wed, 21 Dec 2016 21:19:22 +0000 (+0100) Subject: python/demos/demo_pyaudio.py: add some comments, avoid overwriting aubio.pitch X-Git-Tag: 0.4.4~26 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=62336bb62a65cb1ce1705ed7187eab9e45677f19;p=aubio.git python/demos/demo_pyaudio.py: add some comments, avoid overwriting aubio.pitch --- diff --git a/python/demos/demo_pyaudio.py b/python/demos/demo_pyaudio.py index 205a58de..4c14cd54 100755 --- a/python/demos/demo_pyaudio.py +++ b/python/demos/demo_pyaudio.py @@ -1,9 +1,18 @@ #! /usr/bin/env python +# Use pyaudio to open the microphone and run aubio.pitch on the stream of +# incoming samples. If a filename is given as the first argument, it will +# record 5 seconds of audio to this location. Otherwise, the script will +# run until Ctrl+C is pressed. + +# Examples: +# $ ./python/demos/demo_pyaudio.py +# $ ./python/demos/demo_pyaudio.py /tmp/recording.wav + import pyaudio import sys import numpy as np -from aubio import pitch, sink +import aubio # initialise pyaudio p = pyaudio.PyAudio() @@ -23,7 +32,7 @@ if len(sys.argv) > 1: # record 5 seconds output_filename = sys.argv[1] record_duration = 5 # exit 1 - outputsink = sink(sys.argv[1], samplerate) + outputsink = aubio.sink(sys.argv[1], samplerate) total_frames = 0 else: # run forever @@ -34,7 +43,7 @@ else: tolerance = 0.8 win_s = 4096 # fft size hop_s = buffer_size # hop size -pitch_o = pitch("default", win_s, hop_s, samplerate) +pitch_o = aubio.pitch("default", win_s, hop_s, samplerate) pitch_o.set_unit("midi") pitch_o.set_tolerance(tolerance)