import sounddevice as sd
import matplotlib.pyplot as plt
import numpy as np
import platform
if __name__ == '__main__':
fs = 48000 duration = 100e-3
if platform.system() == 'Windows':
device = 'Microphone (MicNode) MME'
elif platform.system() == 'Darwin':
device = 'MicNode'
else:
device ='default'
myrecording = sd.rec(int(duration * fs), samplerate=fs, channels=1, dtype='int16', device=device)
print('Waiting...')
sd.wait() print('Done!')
time = np.arange(0, duration, 1 / fs) plt.plot(time, myrecording)
plt.xlabel('Time [s]')
plt.ylabel('Amplitude')
plt.title('MicNode')
plt.show()