Page MenuHomePhabricator

test_simple_mix.py
No OneTemporary

test_simple_mix.py

"""
将人声和伴奏合并起来
1. 人声重采样到44k
2.
"""
import os
import time
gs_draw_volume = "/Users/yangjianli/linux/opt/soft/bin/draw_volume"
gs_simple_mixer = "/Users/yangjianli/linux/opt/soft/bin/simple_mixer"
gs_ffmpeg = "/usr/local/bin/ffmpeg"
def process(dir):
"""
文件夹下要求:
1. effect.wav
2. vocal.wav
3. acc.wav
中间结果: effect_442.wav, effect_442_dv.wav
最终输出: mix.wav
:param dir:
:return:
"""
st = time.time()
effect_wav = os.path.join(dir, "effect.wav")
effect442_wav = os.path.join(dir, "effect_442.wav")
effect442dv_wav = os.path.join(dir, "effect_442_dv.wav")
mix_wav = os.path.join(dir, "mix.wav")
vocal_wav = os.path.join(dir, "vocal.wav")
acc_wav = os.path.join(dir, "acc.wav")
if not os.path.exists(effect_wav):
print("no {}".format(effect_wav))
return -1
if not os.path.exists(vocal_wav):
print("no {}".format(vocal_wav))
return -1
if not os.path.exists(acc_wav):
print("no {}".format(acc_wav))
return -1
# 转码到44k双声道
cmd = "{} -i {} -ar 44100 -ac 2 -y {}".format(gs_ffmpeg, effect_wav, effect442_wav)
os.system(cmd)
if not os.path.exists(effect442_wav):
print("err! {}".format(cmd))
return -2
# 拉伸
cmd = "{} {} {} {}".format(gs_draw_volume, effect442_wav, vocal_wav, effect442dv_wav)
os.system(cmd)
if not os.path.exists(effect442dv_wav):
print("err! {}".format(cmd))
return -1
# 合并
cmd = "{} {} {} {}".format(gs_simple_mixer, effect442dv_wav, acc_wav, mix_wav)
os.system(cmd)
if not os.path.exists(mix_wav):
print("err! {}".format(cmd))
return -1
print("{} success! sp={}".format(dir, time.time() - st))
return 0
if __name__ == '__main__':
process(
"/Users/yangjianli/starmaker-work/research/tmp_code/SVC方案调研/prod/out_0327/test/me_3_w4_10_compare_v3_src/611752105020336950")

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 22:39 (22 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1326561
Default Alt Text
test_simple_mix.py (1 KB)

Event Timeline