2noise / ChatTTS

A generative speech model for daily dialogue.
https://2noise.com
Other
26.58k stars 2.89k forks source link

I transribe a list of text, but their voice doesn't come from the same person? Is there an api doc to solve this ? #492

Closed lllllliuji closed 1 day ago

lllllliuji commented 2 days ago
import ChatTTS
import torch
import torchaudio

chat = ChatTTS.Chat()
chat.load(compile=True)  # Set to True for better performance

rand_spk = chat.sample_random_speaker()
params_infer_code = ChatTTS.Chat.InferCodeParams(
    spk_emb=rand_spk,  # add sampled speaker
    temperature=.3,   # using custom temperature
    top_P=0.7,        # top P decode
    top_K=20,         # top K decode
)

texts = [
    "钱塘江上潮信来,今日方知我是我.",
    "先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。"
]

wavs = chat.infer(
    texts,
    params_infer_code=params_infer_code,
)
for i in range(len(wavs)):
    fileName = "output_" + str(i) + ".wav"
    torchaudio.save(fileName, torch.from_numpy(wavs[i]), 24000)
fumiama commented 1 day ago

You can try the latest commit, it has been fixed according to the test on my machine.