ubuntu下的chattts 学习4:Advanced Usage

源码

import ChatTTS
import torch
import torchaudio

chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance
###################################
# Sample a speaker from Gaussian.

rand_spk = chat.sample_random_speaker()
print(rand_spk) # save it for later timbre recovery

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
)

###################################
# For sentence level manual control.

# use oral_(0-9), laugh_(0-2), break_(0-7)
# to generate special token in text to synthesize.
params_refine_text = ChatTTS.Chat.RefineTextParams(
    prompt='[oral_2][laugh_0][break_6]',
)
#
# wavs = chat.infer(
#     texts,
#     params_refine_text=params_refine_text,
#     params_infer_code=params_infer_code,
# )

###################################
# For word level manual control.
text = '故事中国网是《故事会》杂志社主办的网站。网站内容丰富,与杂志期刊《故事会》同步更新'
# text = 'What is [uv_break]your favorite english food?[laugh][lbreak]'
wavs = chat.infer(text, skip_refine_text=True, params_refine_text=params_refine_text,  params_infer_code=params_infer_code)
"""
In some versions of torchaudio, the first line works but in other versions, so does the second line.
"""
try:
    torchaudio.save("word_level_output.wav", torch.from_numpy(wavs[0]).unsqueeze(0), 24000)
except:
    torchaudio.save("word_level_output.wav", torch.from_numpy(wavs[0]), 24000)

运行结果

(chattts) duyicheng@duyicheng-computer:~/gitee/ChatTTS$ python adver.py
蘁淰敝欀俄杔椕贞溮槞聗諐夶糾橌檅盯腀谒淟蛃訋豱梇滑滰螺摅秺艢衧抙掀虌儰虽砸川瓉拻揠跒筞恁嗁哳榾咉汓戤孫誫絭菴爧榩盀儜焇犿圚攺囍笖噹川倓愣拰脂猝橁浾背猚彤猣挿凐厅缾姌談牘縗妏聬茅蕣濱考睰团凒蓈忼衧沯趿妶笛揦耊蒰汵猁勸嚥涅奯凚恭焼蚆氋詝呪蕵耐冇易窽焥偵勡珌炋嚒懇襗唒毨廹矈呎愬蝧栌篕擓蜥淸綊彌蓂貗徼籝睵賠恇渾弨橺脋愻矶冊蒆暹亍粽挪瑆櫃渐秄柣懔檄縻朊栜祥侘请梐絅榉寺壐灾禽壠嚹晻儈嶳嫪椭庛厭佟胂偩變僎沐勊臎蟨粅斆喷橧埸凚昒杊枚渮刎炕涸囁墀炊灾玼粃茢伄呻綕盚緆浖廢喞衖僞睞刭澴跊戢偼衭嘏爒棵暢沠祥蕪讠蜏狖姞檵咰洂粨徥殘凩召偿勻犬乞歯孈脡綂疈獤泀赵瞽湆盛眚薓栨柱薨吺扸焓蘇捃漪泿瓘胼芊冢啟蒄缂籐砗徜忸晘给葇扫茐啨澔示庰慙灌譨痒稍炕籯贊絿儝峄堔瀀濠糍眨擵瓙聂謵袬愐棭漀糟貏壊褉粹厤蠂瑖炩咾株棁樽慥巖蝫蕲眉葌煭嬢牅亓婪叠烑妔瓐篆胢埼蓲话掎媧欁楠谛妤珫聦拗虾忈櫵炬慼裏囕眎桹摴赝蚃唵杲襮尯勹将糊峵峌虓楆忸狧戅仸曧滦戡恐菔纩爼忍宆艧朣庮佃漨堿曺昣平奧拾盟凫涧桝係褝豬扎磰昋洇碟伔礚嫔孄侲嗆舌汵澰慗谯憛簧眩冗怉茦帖丹俬喳痃缕擳周撺賕拑狣疑塒漴流谮俬渼悤篴路槅桯莒聑舯觙痃玼劯叶賃婝視疑眏啽件湚溠屰硶榪妿瞬时氆待垙貟汜燿撾矵笏萾燏燜蛾攬沮糮擌豜啯沥胦洭蛶悬塾婓翚朝诀一㴅
found invalid characters: {'》', '《'}
code:   0%|                                                                                                                                                                                     | 1/2048(max) [00:00,  2.75it/s]We detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class (https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)
code:  16%|████████████████████████████▎                                                                                                                                                      | 324/2048(max) [00:12, 26.76it/s]
(chattts) duyicheng@duyicheng-computer:~/gitee/ChatTTS$

 中英都可以。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PyAIGCMaster

1毛钱也是爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值