我找到了pyDub,看起来就像我需要的那样:
唯一的问题是产生沉默.pyDub可以这样做吗?
基本上我想要的工作流程是:
这可能吗?我意识到我可以创建一个沉默的WAV并以这种方式(间隔GIF闪回,任何人?),但我更喜欢以编程方式生成静音,因为我可能想要尝试沉默和/或比特率的持续时间的MP3.
我非常感谢任何回复.
我想使用pyDub将单个单词的长WAV文件(以及其间的静音)作为输入,然后去掉所有的静音,并输出剩余的块是单独的WAV文件.文件名可以只是序列号,如001.wav,002.wav,003.wav等.
Github页面上的" 又一个示例? "示例执行的操作非常相似,但它不是输出单独的文件,而是将静音剥离的段组合在一起形成一个文件:
from pydub import AudioSegment
from pydub.utils import db_to_float
# Let's load up the audio we need...
podcast = AudioSegment.from_mp3("podcast.mp3")
intro = AudioSegment.from_wav("intro.wav")
outro = AudioSegment.from_wav("outro.wav")
# Let's consider anything that is 30 decibels quieter than
# the average volume of the podcast to be silence
average_loudness = podcast.rms
silence_threshold = average_loudness * db_to_float(-30)
# filter out the silence
podcast_parts = (ms for ms in podcast if ms.rms > silence_threshold)
# combine all the chunks back together …Run Code Online (Sandbox Code Playgroud)