1.使用剪影-文本-智能字幕,智能识别出字幕
2.导出-字幕,导出txt和src两种类型的字幕
3.使用百度翻译将英文字幕txt翻译成中文字幕txt
4.适应python脚本根据英文字幕src将英文替换成中文,生成中文src字幕,脚本如下:
def read_text(text_file): qukongge_list = [] #读取英文 with open(text_file,encoding="utf-8") as f: yinwen_list = f.readlines() # print(yinwen_list) # print(len(yinwen_list)) for one in yinwen_list: if one.strip("\n") !="": qukongge_list.append(one) print(qukongge_list) print(len(qukongge_list)) return qukongge_list def tihuan_text(one_file,one_list,two_list,two_file): with open(one_file,encoding="utf-8") as f: yinzimu_list = f.readlines() yinzimu_list_len = len(yinzimu_list) for j in range(0,yinzimu_list_len): one_wai = yinzimu_list[j] if len(one_list) == len(two_list): for i in range(0,len(one_list)): if one_list[i].strip("\n") in one_wai: yinzimu_list[j] = yinzimu_list[j].replace(one_list[i].strip("\n"),two_list[i].strip("\n")) break print(yinzimu_list) with open(two_file,'w',encoding="utf-8") as f: f.writelines(yinzimu_list) yinwen_list = read_text("英文字幕.txt") zhongwen_list = read_text("中文字幕.txt") tihuan_text(one_file="英文时间.srt", one_list=yinwen_list, two_list=zhongwen_list, two_file="zhongwen.srt")
5.在 使用剪映将视频与字幕合并,导出视频,音频,字幕
标签:中文,text,list,字幕,len,yinzimu,翻译成,file From: https://www.cnblogs.com/jingzaixin/p/17453862.html