加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
EasyVoicePackTool.py 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
Trotsky 提交于 2020-06-21 02:34 . 2
import glob
import json
import os
files = glob.glob("*.mp3")
with open('./temp.json', "r") as f:
temp = json.load(f, encoding="utf-8")
mapper = {tuple(i["keywords"]): i['voices'][0][0:i['voices'][0].find('0')]
for i in temp["contributes"]}
keys = [i["keywords"] for i in temp["contributes"]]
num = len(keys)
for i, ix in enumerate(temp["contributes"]):
ix["voices"] = files[i * len(files) // len(keys)
:(i+1) * len(files) // len(keys)]
for i, ix in enumerate(temp["contributes"]):
for j, jx in enumerate(ix["voices"]):
oldname = jx
os.rename(oldname, oldname+'_')
for i, ix in enumerate(temp["contributes"]):
for j, jx in enumerate(ix["voices"]):
oldname = jx
newname = mapper[tuple(ix["keywords"])] + f'{j + 1:02d}.mp3'
os.rename(oldname+'_', newname)
ix["voices"][j] = newname
os.remove('./contributes.json')
with open('./contributes.json', "w+") as f:
json.dump(temp, f)
info = {
"name": "RedAlert-Voice-Pack", #文件夹名称
"display-name": "RedAlert Voice Pack", #语音包名称
"avatar": "avatar.jpg", #封面
"avatar-dark": "avatar-dark.jpg", #暗光风格封面
"version": "0.0.1", #版本号
"description": "Let's Rock! Commander!", #简介
"languages": ["javascript"], #在哪些编程环境下启用本语音包
"author": "Trotsky1997 Coded.Music by©EA-WestWood", #作者
"gender": "female", #发音性别
"locale": "en" #发音语言
}
os.remove('./manifest.json')
with open('./manifest.json', "w+") as f:
json.dump(info, f)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化