如何从声音流中提取特征?
我尝试将htk
,pytorch
或其他库用于filterbank。
但是他们需要加载wav文件。
我想直接处理pyaudio的麦克风输入。
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=44100, input=True)
while stream.is_active():
input = stream.read(CHUNK)
答案 0 :(得分:0)
您可以使用librosa,非常漂亮的标准库。您需要流功能:
https://librosa.github.io/librosa/generated/librosa.core.stream.html
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=44100, input=True)
stream = librosa.stream(stream,
block_length=256,
frame_length=2048,
hop_length=2048)
for y_block in stream:
m_block = librosa.feature.melspectrogram(y_block, sr=sr,
n_fft=2048,
hop_length=2048,
center=False)