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$

中英都可以。

相关推荐
云上艺旅11 小时前
K8S学习之基础七十四:部署在线书店bookinfo
学习·云原生·容器·kubernetes
你觉得20511 小时前
哈尔滨工业大学DeepSeek公开课:探索大模型原理、技术与应用从GPT到DeepSeek|附视频与讲义下载方法
大数据·人工智能·python·gpt·学习·机器学习·aigc
cg501711 小时前
Spring Boot 的配置文件
java·linux·spring boot
暮云星影11 小时前
三、FFmpeg学习笔记
linux·ffmpeg
rainFFrain12 小时前
单例模式与线程安全
linux·运维·服务器·vscode·单例模式
GalaxyPokemon12 小时前
Muduo网络库实现 [九] - EventLoopThread模块
linux·服务器·c++
mingqian_chu12 小时前
ubuntu中使用安卓模拟器
android·linux·ubuntu
A旧城以西12 小时前
数据结构(JAVA)单向,双向链表
java·开发语言·数据结构·学习·链表·intellij-idea·idea
无所谓จุ๊บ12 小时前
VTK知识学习(50)- 交互与Widget(一)
学习·vtk
FAREWELL0007512 小时前
C#核心学习(七)面向对象--封装(6)C#中的拓展方法与运算符重载: 让代码更“聪明”的魔法
学习·c#·面向对象·运算符重载·oop·拓展方法