Skip to content

Instantly share code, notes, and snippets.

@daguiam
Created February 15, 2023 16:13
Show Gist options
  • Save daguiam/037c421ac96140ed34be93cd29807878 to your computer and use it in GitHub Desktop.
Save daguiam/037c421ac96140ed34be93cd29807878 to your computer and use it in GitHub Desktop.
import sounddevice as sd
import numpy as np
import scipy.io.wavfile as wav
# print(sd.query_devices())
device_list = sd.query_devices()
# find and select index of Line (UMIK-2)
device_str = "Line (UMIK-2), MME"
for device in device_list:
# print(device)
if device_str in device["name"]:
device_name = device["name"]
device_index = device["index"]
break
print("Selected device:",device_index,device_name)
sd.default.device = device_index
fs_recording = 192000
dt_recording = 1/fs_recording
duration = 0.5 #
N_recording = int(fs_recording*duration)
# Start recording:
recording = sd.rec(N_recording, samplerate=fs_recording, channels=1, dtype='float64')
time_recording = np.arange(len(recording))*dt_recording
# wait for recording to complete
sd.wait()
plt.plot(time_recording, recording)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment