split_on_silence修改原始音频

时间:2018-09-04 12:21:22

标签: python audio

使用split_on_silence后的音频转换:
例如:
原文:您好,我叫约翰。 块:
chunk1:ell
chunk2:名称

我的代码:

from pydub import AudioSegment
from pydub.silence import split_on_silence

song = AudioSegment.from_wav("videofr.wav")
#split track where silence is 0.2 seconds or more and get chunks
chunks = split_on_silence(song,
    # must be silent for at least 0.2 seconds or 200 ms
    min_silence_len=200,
                            )
cpt = 0
print(len(song))
for i,chunk in enumerate(chunks):
    print((chunk))
    print(len(chunk))
    cpt = cpt + 1
    chunk.export(".//chunk{0}.wav".format(i), format="wav")

1 个答案:

答案 0 :(得分:0)

尝试更改min_silence_lensilence_thresh的值,以尽可能接近实际的静默持续时间和dbFS级别。 例如

chunks = split_on_silence(song,
    # must be silent for at least 0.2 seconds or 200 ms
    min_silence_len=200,

    # consider it silent if quieter than -16 dBFS
    silence_thresh=-16

您可以通过将文件加载到audacity中并在句子结尾处检查静默持续时间和幅度来验证实际值。