LoginSignup
0
0

More than 3 years have passed since last update.

SoxとPythonでステレオをモノラルに一括変換

Posted at

ステレオモノラル一括変換

pythonでフォルダ内のファイル全て取得して、
soxでステレオモノラル変換させる。

brew install sox
# USAGE
#python streo2mono.py input output
#python streo2mono.py FOLDER_PATH
import subprocess
import sys
import os


file_path = sys.argv[1]
output_path = sys.argv[2]
file_list = os.listdir(path=sys.argv[1])

cmd_mkdir = "mkdir %s" % (output_path)
subprocess.call(cmd_mkdir, shell = True)

for i in range(len(file_list)):
    if(file_list[i]==".DS_Store"):
        print("find DSSTORE")
    else:
        input_file = file_path + file_list[i]
        output_file = output_path  +file_list[i]
        cmd = "sox %s %s remix 1,2" % (input_file, output_file)
        subprocess.call(cmd, shell = True)
        print("s --> m ::"+file_list[i])

print("done")
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0