Ai
1 Star 0 Fork 7

厉莘/Sound_File_Processing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
shour_file_plicing_and_rename_to_num.py 934 Bytes
一键复制 编辑 原始数据 按行查看 历史
李子 提交于 2021-12-10 00:15 +08:00 . 通过序号给文件重命名
import os
import shutil
from short_file_plicing import main
from utils.file_io import file_r, file_w
if __name__ == '__main__':
# main()
num = 1
sound_root_path = "wav"
transcript_root_path = "transcript"
new_transcript_path = transcript_root_path + "/" + "transcript_new.txt"
transcript_text = file_r(transcript_root_path + "/transcript.txt")
if not os.path.exists(sound_root_path+"/output_rename/"):
os.mkdir(sound_root_path+"/output_rename/")
for text_line in transcript_text.split("\n"):
file_txt = "".join(text_line.split(" ")[1:])
if len(file_txt) == 0:
continue
file_name = str(num)
new_line = str(num) + " " + file_txt + "\n"
file_w(new_transcript_path, new_line, "a")
shutil.copy(sound_root_path + "/output/" + text_line.split(" ")[0] + ".wav",sound_root_path + "/output_rename/" + file_name + ".wav")
num += 1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/amonraknight/Sound_File_Processing.git
git@gitee.com:amonraknight/Sound_File_Processing.git
amonraknight
Sound_File_Processing
Sound_File_Processing
master

搜索帮助