2 Star 30 Fork 7

李子/Sound_File_Processing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rename_by_txt.py 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
李子 提交于 2021-11-21 21:54 . 去掉文件名前的序号
import os
import shutil
from utils.file_io import file_r, file_w
if __name__ == '__main__':
sound_root_path = "wav"
transcript_root_path = "transcript"
transcript_text = file_r(transcript_root_path + "/transcript.txt")
transcript_text_new = ""
is_full_old_name = 1
count = 1
if not os.path.exists(sound_root_path+"/output_rename_by_txt/"):
os.mkdir(sound_root_path+"/output_rename_by_txt/")
for line in transcript_text.split("\n"):
if len(line) == 0:
continue
line_file_name = line.split(" ")[0]
line_file_txt = "".join(line.split(" ")[1:])
if is_full_old_name == 1:
line_file_name_new = line_file_name+"_"+line_file_txt
else:
line_file_name_new = line_file_txt
transcript_text_new = transcript_text_new + line_file_name_new + " " + line_file_txt + "\n"
shutil.copy(sound_root_path+"/output/"+line_file_name+".wav", sound_root_path+"/output_rename_by_txt/"+line_file_name_new+".wav")
count = count+1
file_w(transcript_root_path + "/transcript_rename_by_txt.txt", transcript_text_new, "a")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/kslizi/Sound_File_Processing.git
git@gitee.com:kslizi/Sound_File_Processing.git
kslizi
Sound_File_Processing
Sound_File_Processing
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385