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$

中英都可以。

相关推荐
大帅哥_3 分钟前
Linux的几个基本指令
linux·服务器
davenian19 分钟前
< OS 有关 > 阿里云:轻量应用服务器 的使用 安装 Tailscale 后DNS 出错, 修复并替换 apt 数据源
linux·服务器·ubuntu·阿里云·tailscale
乔木剑衣1 小时前
微服务学习:基础理论
学习·微服务·架构
Icoolkj1 小时前
微服务学习-Nacos 作为配置中心动态管理
java·学习·微服务
DZSpace2 小时前
安装k8s前置操作(Ubuntu / CentOS)
ubuntu·kubernetes·centos
千航@abc2 小时前
vim文本编辑器
linux·运维·编辑器·vim
千航@abc2 小时前
vim文本编辑器三种模式的转换关系
linux·运维·编辑器·vim
卜及中2 小时前
【Sanic 框架 / 1】深入学习:从入门到进阶
python·学习·web3·python3.11
爱吃喵的鲤鱼2 小时前
Linux——多线程的控制
linux·运维·服务器
吹个泡泡(c++后端开发)3 小时前
linux之进程信号(信号保存 & 信号处理)
linux·信号处理