Open uspear opened 2 months ago
这个是我改写的代码 `
获取prompt配置
def get_prompt_by_id(prompt_id): """ - 根据prompt_id获取配置 - 设置克隆音频路径、克隆音频提示文本、克隆音频提示文本的语言 - 模型 """ file_path = r"./prompt/config.json" try: with open(file_path, 'r', encoding='utf-8') as file: data = json.load(file) # 确保数据结构与你的json文件匹配 return data.get(prompt_id, [])
except FileNotFoundError: print(f"文件未找到:{file_path}") return None except json.JSONDecodeError: print(f"解析JSON错误,请检查{file_path}的格式") return None except Exception as e: print(f"发生未知错误:{e}") return None
async def tts_endpoint(promptName,text): prompt_config = get_prompt_by_id(promptName) text_language = "en" cut_punc = None return handle(prompt_config['prompt_wav_path'], prompt_config['prompt_text'], prompt_config['prompt_language'], text, text_language, cut_punc)
if name == "main": text = "hello" tts_endpoint("abc",text ) ` 以下是程序运行返回的截图
额,这位仁兄,问一下,怎么通过api调用
这个是我改写的代码 `
获取prompt配置
def get_prompt_by_id(prompt_id): """
模型 """ file_path = r"./prompt/config.json"
try: with open(file_path, 'r', encoding='utf-8') as file: data = json.load(file)
确保数据结构与你的json文件匹配
except FileNotFoundError: print(f"文件未找到:{file_path}") return None except json.JSONDecodeError: print(f"解析JSON错误,请检查{file_path}的格式") return None except Exception as e: print(f"发生未知错误:{e}") return None
async def tts_endpoint(promptName,text): prompt_config = get_prompt_by_id(promptName) text_language = "en" cut_punc = None return handle(prompt_config['prompt_wav_path'], prompt_config['prompt_text'], prompt_config['prompt_language'], text, text_language, cut_punc)
if name == "main": text = "hello" tts_endpoint("abc",text ) ` 以下是程序运行返回的截图![image](https://github.com/RVC-Boss/GPT-SoVITS/assets/48174228/6bfd7c1a-1e00-41c3-817d-7e8ee3a9d71f)