【问题标题】:How to read a audio file in Python similar to Matlab audioread?如何在 Python 中读取类似于 Matlab audioread 的音频文件?
【发布时间】:2016-09-04 10:45:25
【问题描述】:

我在 Python 中使用 wavefile.read() 将音频文件导入 Python。我想要的是读取一个音频文件,其中每个样本都是双倍并标准化为 -1.0 到 +1.0,类似于 Matlab audioread() 函数。我该怎么做?

【问题讨论】:

    标签: python matlab audio


    【解决方案1】:

    使用PySoundFile 包的read 函数。默认情况下,它将完全返回您所要求的内容:一个 numpy 数组,其中包含 -1.0+1.0 范围内的双精度 (Float64) 格式的声音文件样本。

    【讨论】:

      【解决方案2】:

      使用 Scipy:

      将 scipy.io.wavfile 导入为 wav

      fs,signal=wav.read(file_name)

      信号 /= 32767

      如果您想要与 Matlab 中完全相同的东西,则需要除以 max int。警告:如果 wav 文件是 int32 编码的,则需要通过 max int32 进行归一化

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-16
        • 1970-01-01
        • 2021-03-26
        • 2014-02-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多