scipy.io.wavfile.Read返回说明

发布于 2025-01-29 06:02:58 字数 533 浏览 5 评论 0原文

我知道我可以通过https://docs.scipy.org/doc/scipy/referency/generated/scipy.io.wavfile.read.html读取它,但我太愚蠢了,无法理解它。

from scipy.io.wavfile import read
sample_rate, data = read("./drive/MyDrive/PSD.wav")
print(len(data))
print(data)

数据的长度数组的什么表示?我有输出1500000,但是它是什么意思或使用了什么单位? sample_rate是488000,我想我了解这一点,但我不确定。

当我打印数据时,它给了我输出,

[[  0   0]
 [  0   0]
 [  0   0]
 ...
 [-25 -25]
 [ 18  18]
 [ -4  -4]]

我知道它已经离开通道和右通道,但是什么是振幅单元?

I know I can read it at https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.wavfile.read.html, but I'm too stupid to understand it.

from scipy.io.wavfile import read
sample_rate, data = read("./drive/MyDrive/PSD.wav")
print(len(data))
print(data)

What representation of length array of data? I have output 1500000 but what does it mean or what unit it used? And sample_rate is 488000, I think I understand about it but I'm not sure.

And when I printed the data it gave me output

[[  0   0]
 [  0   0]
 [  0   0]
 ...
 [-25 -25]
 [ 18  18]
 [ -4  -4]]

I know it has left channel and right channel, but what is amplitude units?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好多鱼好多余 2025-02-05 06:02:58

如果您有两个列数组,则意味着您的Wave文件具有两个通道(立体声,左/右)。采样率每秒给出样本数量,因此采样周期为(1 / sampe_rate)< / code>。

你也可以绘制它

import matplotlib.pyplot as plt
import numpy as np
# time for each sample
t = np.arange(len(data)) / sample_rate
plt.subplot(211)
plt.plot(t, data[:,0]);
plt.subplot(212)
plt.plot(t, data[:,1]);

If you have a two columns arrays it means your wave file has two channels (stereo, left/right). The sample rate gives the number of samples per second, so the sampling period is (1 / sample_rate).

You could plot it as well

import matplotlib.pyplot as plt
import numpy as np
# time for each sample
t = np.arange(len(data)) / sample_rate
plt.subplot(211)
plt.plot(t, data[:,0]);
plt.subplot(212)
plt.plot(t, data[:,1]);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文