Skip to content

Instantly share code, notes, and snippets.

@7m4mon
Created December 13, 2023 11:45
Show Gist options
  • Save 7m4mon/afa827d643ceee59fbfc0a3916f754fa to your computer and use it in GitHub Desktop.
Save 7m4mon/afa827d643ceee59fbfc0a3916f754fa to your computer and use it in GitHub Desktop.
フォルダ内のwavファイルを連結して保存する
# -*- coding: utf-8 -*-
# フォルダ内のwavファイルを連結して保存する
import glob
from pydub import AudioSegment
files = glob.glob("C:/tmp/*.wav")
sound = AudioSegment.empty()
for file in files:
print(file)
# 音声ファイルの読み込み
sound1 = AudioSegment.from_file(file, "wav")
# 連結
sound += sound1
# 保存
sound.export("./output.wav", format="wav")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment