diff options
| author | hathach <[email protected]> | 2021-04-15 12:08:50 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-04-15 12:08:50 +0700 |
| commit | ad11481dd16112a38ab05754bafb33599af38f9d (patch) | |
| tree | c6ba48e10558a6ca70562ffe25b175d8e4d514e7 /examples/device/audio_test/src/plot_audio_samples.py | |
| parent | 8d9f60ca5e1b095fd8ab5541bf3190a2035eaf6f (diff) | |
update plot script to work on macos and linux
also add note for installing pip module
Diffstat (limited to 'examples/device/audio_test/src/plot_audio_samples.py')
| -rw-r--r-- | examples/device/audio_test/src/plot_audio_samples.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/examples/device/audio_test/src/plot_audio_samples.py b/examples/device/audio_test/src/plot_audio_samples.py index 0b0c3394f..6e3c4978e 100644 --- a/examples/device/audio_test/src/plot_audio_samples.py +++ b/examples/device/audio_test/src/plot_audio_samples.py @@ -1,15 +1,24 @@ import sounddevice as sd import matplotlib.pyplot as plt import numpy as np +import platform if __name__ == '__main__': - # devList = sd.query_devices() - # print(devList) + # If you got "ValueError: No input device matching", that is because your PC name example device + # differently from tested list below. Uncomment the next line to see full list and try to pick correct one + # print(sd.query_devices()) - fs = 48000 # Sample rate - duration = 100e-3 # Duration of recording - device = 'Microphone (MicNode) MME' # MME is needed since there are more than one MicNode device APIs (at least in Windows) + fs = 48000 # Sample rate + duration = 100e-3 # Duration of recording + + if platform.system() == 'Windows': + # MME is needed since there are more than one MicNode device APIs (at least in 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...') |
