我正在做一个使用 sounddevice 来录制声音的项目。我还需要为项目使用声音的频率和音量。我已经弄清楚如何录制声音,但是我无法弄清楚如何操作存储录制声音的数组,因为我不知道任何值对应于什么。我尝试在网上查找 sounddevice 中的数组是如何工作的,但信息要么不存在,要么对我没有意义。
当我尝试打印数组时,我得到了这个:
array([[ 0.0000000e+00, 0.0000000e+00],
[-3.0517578e-05, 0.0000000e+00],
[ 0.0000000e+00, 0.0000000e+00],
...,
[-2.0446777e-02, -2.0416260e-02],
[-1.3946533e-02, -1.3946533e-02],
[ 2.7465820e-04, 2.7465820e-04]], dtype=float32)
这是 sounddevice 文档的链接:https ://python-sounddevice.readthedocs.io/en/0.3.15/
这是我用来录制声音的:
import sounddevice as sd
#from scipy.io.wavfile import write
#from derivatives import slope
import numpy as np
fs = 45000
seconds = 1
test = input()
if test == '':
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)
print('recording')
sd.wait()
print('done recording')
#write('output.wav', fs, myrecording)