Break out handling of pyaudio stuff into functions.