python で音声ファイルから特定の部分を抽出する

参考

【Python/pydub】mp3、wavファイルから部分抽出(切り分け、分割)

コード

def extract_sound(input_file_path, output_file_path, start_seconds, end_seconds):
    sound = AudioSegment.from_file(input_file_path, format="mp3")
    start = start_seconds * 1000
    end = end_seconds * 1000
    extracted_sound = sound[start:end]
    extracted_sound.export(output_file_path)
YouTube