I am using Soundflower to redirect the sound from applications.
import pyaudio import numpy as np import matplotlib.pyplot as plt CHUNK = 8192 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100 p = pyaudio.PyAudio() stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK) fig = plt.figure(1, figsize=(18,6)) ax = plt.subplot(1,1,1) ax.set_xlim(0, CHUNK-1) x = range(CHUNK) y = np.zeros(CHUNK) lines, = plt.plot(x,y) for i in range(5000): data = stream.read(CHUNK, exception_on_overflow = False) y = np.frombuffer(data, dtype="int16") y_max = 1.1 * max(abs(y.min()), abs(y.max())) ax.set_ylim(-y_max, y_max) lines.set_data(x,y) plt.pause(1) stream.stop_stream() stream.close() p.terminate()