2noise / ChatTTS

A generative speech model for daily dialogue.
https://2noise.com
GNU Affero General Public License v3.0
32.61k stars 3.54k forks source link

尝试封装兼容OpenAPI请求的接口,每个字都被做了分词 #815

Closed sanpatricky closed 3 weeks ago

sanpatricky commented 3 weeks ago

现象:

[+0800 20241104 21:41:57] [INFO] Command | main | Text input: ['四', '川', '美', '食', '确', '实', '以', '辣', '闻', '名', ',', '但', '也', '有', '不', '辣', '的', '选', '择', '。', '比', '如', '甜', '水', '面', '、', '赖', '汤', '圆', '、', '蛋', '烘', '糕', '、', '叶', '儿', '粑', '等', ',', '这', '些', '小', '吃', '口', '味', '温', '和', ',', '甜', '而', '不', '腻', ',', '也', '很', '受', '欢', '迎', '。']
text:   1%|█▊                                                                                                                                       | 5/384(max) [00:13,  2.77s/it]
[+0800 20241104 21:42:25] [INFO] Command | main | Refined text: ['四', '川', '美', '食', '确', '实', '以', '辣', '闻', '名', ',', '但', '也', '有', '不', '辣', '的', '选', '择', '。', '比', '如', '甜', '水', '面', '、', '赖', '汤', '圆', '、', '蛋', '烘', '糕', '、', '叶', '', '粑', '等', ',', '这', '些', '小', '吃', '口', '味', '温', '和', ',', '甜', '而', '不', '腻', ',', '也', '很', '受', '欢', '迎', '。 [uv_break]']

代码: examples/api/main.py 中添加:

class OpenAIParams(BaseModel):
        input: str
        voice: str

@app.post("/v1/audio/speech")
async def generate_voice_OpenAI(openAIParams: OpenAIParams):
    # refine text params
    params_refine_text = {
        "prompt": "",
        "top_P": 0.7,
        "top_K": 20,
        "temperature": 0.7,
        "repetition_penalty": 1,
        "max_new_token": 384,
        "min_new_token": 0,
        "show_tqdm": True,
        "ensure_non_empty": True,
        "stream_batch": 24,
    }

    # infer code params
    params_infer_code = {
        "prompt": "[speed_5]",
        "top_P": 0.1,
        "top_K": 20,
        "temperature": 0.3,
        "repetition_penalty": 1.05,
        "max_new_token": 2048,
        "min_new_token": 0,
        "show_tqdm": True,
        "ensure_non_empty": True,
        "stream_batch": True,
        "spk_emb": None,
    }

    chatTTSParams = ChatTTSParams(text=list(openAIParams.input),
                                  params_refine_text=params_refine_text,
                                  params_infer_code=params_infer_code)

    return await generate_voice(chatTTSParams)

感谢!

fumiama commented 3 weeks ago

是你的代码问题,而且你的代码版本太老了,一般来说请先升级到最新版本查看问题是否解决,如果没有,再来发issue。

sanpatricky commented 3 weeks ago

抱歉确实是代码问题,属于低级错误,问题已解决,这个issue已关闭

sanpatricky commented 3 weeks ago

关闭