Created
February 15, 2023 16:13
-
-
Save daguiam/037c421ac96140ed34be93cd29807878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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