-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Haruhiyuki/dev
0.3.0版
- Loading branch information
Showing
15 changed files
with
418 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/.idea | ||
*.pyc | ||
/build | ||
*.spec | ||
*.spec | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"role_model_mapping": { | ||
"长门有希": { | ||
"gpt": "GPT_weights_v2/nagato_yuki-e15.ckpt", | ||
"sovits": "SoVITS_weights_v2/nagato_yuki_e15_s2160.pth" | ||
}, | ||
"your_first_character": { | ||
"gpt": "角色名应与你在表格中填写的角色名相同,熟悉后请新建角色使用", | ||
"sovits": "如果你在本地运行API,请填写本地模型位置,否则请咨询在线服务的提供者" | ||
} | ||
}, | ||
"voice_cmd_mapping": { | ||
"voice_cmd_1": { | ||
"ref_audio_path": "仅当你使用表格中的语音指令列时,才需要用到此项", | ||
"prompt_text": "否则仅需配置默认参考音频及文本便可" | ||
}, | ||
"voice_cmd_2": { | ||
"ref_audio_path": "这一额外参数可帮助你针对不同情况使用不同的参考音频与文本", | ||
"prompt_text": "熟悉后请新建指令使用,选择你需要的命名方式" | ||
} | ||
}, | ||
"default_prompt_audio": "./predef_ref/正常有希/01_有希_平静.wav", | ||
"default_prompt_text": "私が再び異常動作を起こさないという確証はない。", | ||
"API_BASE_URL": { | ||
"base": "http://127.0.0.1:9880/" | ||
}, | ||
"deepL_api_key": "YOUR_DEEPL_API_KEY" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,81 @@ | ||
role_model_mapping = { | ||
"长门": { | ||
"gpt": "GPT_weights_v2/nagato_yuki-e15.ckpt", | ||
"sovits": "SoVITS_weights_v2/nagato_yuki_e15_s2160.pth" | ||
}, | ||
"角色2": { | ||
"gpt": "gpt_model_2_path", | ||
"sovits": "sovits_model_2_path" | ||
}, | ||
# 添加更多角色... | ||
} | ||
import json | ||
import os | ||
|
||
voice_cmd_mapping = { | ||
"voice_cmd_1": { | ||
"ref_audio_path": "path_to_reference_1.wav", | ||
"prompt_text": "Prompt text for voice_cmd_1" | ||
}, | ||
"voice_cmd_2": { | ||
"ref_audio_path": "path_to_reference_2.wav", | ||
"prompt_text": "Prompt text for voice_cmd_2" | ||
}, | ||
# 添加更多映射... | ||
} | ||
class TTSConfig: | ||
def __init__(self, config_file='config.json'): | ||
self.config_file = config_file | ||
self.role_model_mapping = { | ||
"长门有希": { | ||
"gpt": "GPT_weights_v2/nagato_yuki-e15.ckpt", | ||
"sovits": "SoVITS_weights_v2/nagato_yuki_e15_s2160.pth" | ||
}, | ||
"your_first_character": { | ||
"gpt": "角色名应与你在表格中填写的角色名相同,熟悉后请新建角色使用", | ||
"sovits": "如果你在本地运行API,请填写本地模型位置,否则请咨询在线服务的提供者" | ||
}, | ||
# 添加更多角色... | ||
} | ||
self.voice_cmd_mapping = { | ||
"voice_cmd_1": { | ||
"ref_audio_path": "仅当你使用表格中的语音指令列时,才需要用到此项", | ||
"prompt_text": "否则仅需配置默认参考音频及文本便可" | ||
}, | ||
"voice_cmd_2": { | ||
"ref_audio_path": "这一额外参数可帮助你针对不同情况使用不同的参考音频与文本", | ||
"prompt_text": "熟悉后请新建指令使用,选择你需要的命名方式" | ||
}, | ||
# 添加更多映射... | ||
} | ||
self.default_prompt_audio = "./predef_ref/正常有希/01_有希_平静.wav" | ||
self.default_prompt_text = "私が再び異常動作を起こさないという確証はない。" | ||
self.api_base_url = {'base': 'http://127.0.0.1:9880/'} | ||
self.deepL_api_key = "YOUR_DEEPL_API_KEY" | ||
|
||
default_prompt_audio = "D:/GPT-SoVITS-v2-240821/predef_ref/正常有希/01_有希_平静.wav" | ||
default_prompt_text = "私が再び異常動作を起こさないという確証はない。" | ||
if os.path.exists(self.config_file): | ||
self.load_config() | ||
else: | ||
self.save_config() # 创建配置文件并保存默认内容 | ||
|
||
API_BASE_URL = { | ||
'base': 'http://127.0.0.1:9880/' | ||
} | ||
def load_config(self): | ||
with open(self.config_file, 'r', encoding='utf-8') as f: | ||
config = json.load(f) | ||
self.role_model_mapping = config['role_model_mapping'] | ||
self.voice_cmd_mapping = config['voice_cmd_mapping'] | ||
self.default_prompt_audio = config['default_prompt_audio'] | ||
self.default_prompt_text = config['default_prompt_text'] | ||
self.api_base_url = config['API_BASE_URL'] | ||
self.deepL_api_key = config['deepL_api_key'] | ||
|
||
def save_config(self): | ||
config = { | ||
'role_model_mapping': self.role_model_mapping, | ||
'voice_cmd_mapping': self.voice_cmd_mapping, | ||
'default_prompt_audio': self.default_prompt_audio, | ||
'default_prompt_text': self.default_prompt_text, | ||
'API_BASE_URL': self.api_base_url, | ||
'deepL_api_key': self.deepL_api_key | ||
} | ||
with open(self.config_file, 'w', encoding='utf-8') as f: | ||
json.dump(config, f, indent=4, ensure_ascii=False) | ||
|
||
def save_config_gui(self, default_prompt_text, default_prompt_audio, api_base_url, role_model_mapping, voice_cmd_mapping, deepL_api_key): | ||
config = { | ||
'role_model_mapping': role_model_mapping, | ||
'voice_cmd_mapping': voice_cmd_mapping, | ||
'default_prompt_audio': default_prompt_audio, | ||
'default_prompt_text': default_prompt_text, | ||
'API_BASE_URL': api_base_url, | ||
'deepL_api_key': deepL_api_key | ||
} | ||
with open(self.config_file, 'w', encoding='utf-8') as f: | ||
json.dump(config, f, indent=4, ensure_ascii=False) | ||
|
||
def delete_role(self, role_name): | ||
if role_name in self.role_model_mapping: | ||
del self.role_model_mapping[role_name] | ||
self.save_config() # 保存更改后的配置 | ||
|
||
def delete_voice_cmd(self, cmd_name): | ||
if cmd_name in self.voice_cmd_mapping: | ||
del self.voice_cmd_mapping[cmd_name] | ||
self.save_config() # 保存更改后的配置 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.