在做一个scipy.signal.spectrogram的时候,怎么知道会有多少个时间段呢?
When doing a scipy.signal.spectrogram, how can I tell how many time segments there will be?
我有:
frequencies, times, spectrogram = signal.spectrogram(
samples, sample_rate, nperseg=nperseg, window=signal.hann(nperseg), noverlap=noverlap, mode='magnitude')
我有 nperseg=320
和 noverlap=80
,还有一个 sample_rate=16000
。
我有 232800
个样本。
但是,我的 spectrogram.shape
现在是 (161, 969)
。所以这是 161 个频率仓和 969 个时间段。那969是怎么算出来的?
time_per_segment_ms = 20
nperseg = int(sample_rate * 0.001 * time_per_segment_ms)
overlap = nperseg // 4
seconds_per_segment = (nperseg - overlap) / sample_rate
ms_per_segment = int(seconds_per_segment * 1000)
差不多就可以了
我有:
frequencies, times, spectrogram = signal.spectrogram(
samples, sample_rate, nperseg=nperseg, window=signal.hann(nperseg), noverlap=noverlap, mode='magnitude')
我有 nperseg=320
和 noverlap=80
,还有一个 sample_rate=16000
。
我有 232800
个样本。
但是,我的 spectrogram.shape
现在是 (161, 969)
。所以这是 161 个频率仓和 969 个时间段。那969是怎么算出来的?
time_per_segment_ms = 20
nperseg = int(sample_rate * 0.001 * time_per_segment_ms)
overlap = nperseg // 4
seconds_per_segment = (nperseg - overlap) / sample_rate
ms_per_segment = int(seconds_per_segment * 1000)
差不多就可以了