python – 我们如何使用scipy.signal.resample对44100到8000 Hz信号的语音信号进行下采样?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python – 我们如何使用scipy.signal.resample对44100到8000 Hz信号的语音信号进行下采样?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2655字,纯文字阅读大概需要4分钟。
内容图文
fs, s = wav.read('wave.wav')
此信号具有44100 Hz的采样频率,我想将此信号采样到8Khz
scipy.signal.resample(s,s.size / 5.525)但第二个元素不能浮动,那么,我们如何使用此函数重新映射语音信号?
我们如何使用scipy.signal.resample在python中对44100到8000 Hz的语音信号进行下采样?
解决方法:
好吧,那么,另一个解决方案,这个与scipy真实.正是要求的.
这是scipy.signal.resample()的doc字符串:
"""
Resample `x` to `num` samples using Fourier method along the given axis.
The resampled signal starts at the same value as `x` but is sampled
with a spacing of ``len(x) / num * (spacing of x)``. Because a
Fourier method is used, the signal is assumed to be periodic.
Parameters
----------
x : array_like
The data to be resampled.
num : int
The number of samples in the resampled signal.
t : array_like, optional
If `t` is given, it is assumed to be the sample positions
associated with the signal data in `x`.
axis : int, optional
The axis of `x` that is resampled. Default is 0.
window : array_like, callable, string, float, or tuple, optional
Specifies the window applied to the signal in the Fourier
domain. See below for details.
Returns
-------
resampled_x or (resampled_x, resampled_t)
Either the resampled array, or, if `t` was given, a tuple
containing the resampled array and the corresponding resampled
positions.
Notes
-----
The argument `window` controls a Fourier-domain window that tapers
the Fourier spectrum before zero-padding to alleviate ringing in
the resampled values for sampled signals you didn't intend to be
interpreted as band-limited.
If `window` is a function, then it is called with a vector of inputs
indicating the frequency bins (i.e. fftfreq(x.shape[axis]) ).
If `window` is an array of the same length as `x.shape[axis]` it is
assumed to be the window to be applied directly in the Fourier
domain (with dc and low-frequency first).
For any other type of `window`, the function `scipy.signal.get_window`
is called to generate the window.
The first sample of the returned vector is the same as the first
sample of the input vector. The spacing between samples is changed
from dx to:
dx * len(x) / num
If `t` is not None, then it represents the old sample positions,
and the new sample positions will be returned as well as the new
samples.
"""
如您所知,8000 Hz意味着您的信号的一秒钟包含8000个样本,而对于44100 Hz,这意味着一秒钟包含44100个样本.
然后,只计算8000 Hz需要多少样本,并将该数字用作scipy.signal.resample()的第二个参数.
你可以使用Nathan Whitehead在重新采样函数中使用的方法,我在其他答案中进行了修改(使用缩放),
或经过时间,即
secs = len(X)/44100.0 # Number of seconds in signal X
samps = secs*8000 # Number of samples to downsample
Y = scipy.signal.resample(X, samps)
内容总结
以上是互联网集市为您收集整理的python – 我们如何使用scipy.signal.resample对44100到8000 Hz信号的语音信号进行下采样?全部内容,希望文章能够帮你解决python – 我们如何使用scipy.signal.resample对44100到8000 Hz信号的语音信号进行下采样?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。