假设我有两个采样率相同的音频片段,它们是从 Pydub 中的 .wav 文件导入的,并且假设我知道哪个更短。现在假设我想将较长的音频文件分成两个片段,以便第一个片段与较短的音频文件具有完全相同的长度(精确到相同的样本数量!),并将这两个片段中的每一个分配给新的音频片段。我怎样才能在 Pydub 中做到这一点?如果我无法使用 Pydub 获得这种精度,您能给我一个同样有效的替代方案吗?
Basically I just want to split the longer audio segment into two at the sample-perfect level. Here's an illustration of what I want:
您可以使用 AudioSegment().get_array_of_samples() ,然后使用所需的精确样本数构造新片段:
samples = sound.get_array_of_samples()
shorter = sound._spawn(samples[:20000])
注意:此代码未经测试 - 我在我的 iPhone 上编写了它:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)