Pytorch에서 Natural Speech 2, Zero-shot Speech 및 Singing Synthesizer 구현
NaturalSpeech 2는 연속 잠재 벡터가 포함된 신경 오디오 코덱과 비자동회귀 생성 기능이 있는 잠재 확산 모델을 활용하여 자연스러운 제로샷 텍스트 음성 합성을 가능하게 하는 TTS 시스템입니다.
이 저장소는 점수 기반 SDE 대신 노이즈 제거 확산을 사용하며 잠재적으로 설명된 버전도 제공할 수 있습니다. 또한 해당되는 경우 어텐션/변압기 구성요소에 대한 개선도 제공할 것입니다.
안정성과? 최첨단 인공 지능 연구 및 오픈 소스 작업에 대한 아낌없는 후원을 위한 Huggingface
? 놀라운 가속 라이브러리를 위한 Huggingface
음소, 높낮이, 지속 시간, 음성 프롬프트 인코더와 다국어 음소 마이저 및 음소 정렬기에 대한 초기 코드를 제출해 주신 Manmay!
확산 네트워크의 전체 엔드 투 엔드 컨디셔닝을 배선해 주신 Manmay!
너? 야심찬 ML/AI 엔지니어이거나 TTS 분야에서 일하고 있으며 최첨단 오픈 소싱에 기여하고 싶다면 지금 바로 참여하세요!
$ pip install naturalspeech2-pytorch
import torch
from naturalspeech2_pytorch import (
EncodecWrapper ,
Model ,
NaturalSpeech2
)
# use encodec as an example
codec = EncodecWrapper ()
model = Model (
dim = 128 ,
depth = 6
)
# natural speech diffusion model
diffusion = NaturalSpeech2 (
model = model ,
codec = codec ,
timesteps = 1000
). cuda ()
# mock raw audio data
raw_audio = torch . randn ( 4 , 327680 ). cuda ()
loss = diffusion ( raw_audio )
loss . backward ()
# do the above in a loop for a lot of raw audio data...
# then you can sample from your generative model as so
generated_audio = diffusion . sample ( length = 1024 ) # (1, 327680)
컨디셔닝 포함
전.
import torch
from naturalspeech2_pytorch import (
EncodecWrapper ,
Model ,
NaturalSpeech2 ,
SpeechPromptEncoder
)
# use encodec as an example
codec = EncodecWrapper ()
model = Model (
dim = 128 ,
depth = 6 ,
dim_prompt = 512 ,
cond_drop_prob = 0.25 , # dropout prompt conditioning with this probability, for classifier free guidance
condition_on_prompt = True
)
# natural speech diffusion model
diffusion = NaturalSpeech2 (
model = model ,
codec = codec ,
timesteps = 1000
)
# mock raw audio data
raw_audio = torch . randn ( 4 , 327680 )
prompt = torch . randn ( 4 , 32768 ) # they randomly excised a range on the audio for the prompt during training, eventually will take care of this auto-magically
text = torch . randint ( 0 , 100 , ( 4 , 100 ))
text_lens = torch . tensor ([ 100 , 50 , 80 , 100 ])
# forwards and backwards
loss = diffusion (
audio = raw_audio ,
text = text ,
text_lens = text_lens ,
prompt = prompt
)
loss . backward ()
# after much training
generated_audio = diffusion . sample (
length = 1024 ,
text = text ,
prompt = prompt
) # (1, 327680)
또는 Trainer
클래스가 훈련 및 샘플링 루프를 관리하도록 하려면 간단히 다음을 수행하십시오.
from naturalspeech2_pytorch import Trainer
trainer = Trainer (
diffusion_model = diffusion , # diffusion model + codec from above
folder = '/path/to/speech' ,
train_batch_size = 16 ,
gradient_accumulate_every = 2 ,
)
trainer . train ()
완전한 인식자 그런 다음 ddpm 측에서 주의 조건을 교차합니다.
종이에 없더라도 분류자 무료 안내를 추가하세요.
훈련 중 전체 시간/음조 예측 - Manmay 덕분에
파이월드의 피치 계산 방식도 작동하는지 확인하세요
pyworld 사용법에 대해 TTS 분야의 박사 과정 학생에게 문의하세요.
또한 가능한 경우 Spear-tts 텍스트-의미론 모듈을 사용하여 직접 합계 조건을 제공합니다.
ddpm 측에 자체 조절 추가
코덱 모델에서 허용하는 최소 오디오 세그먼트를 인식하여 신속한 오디오 자동 슬라이싱을 처리합니다.
curtail_from_left가 encodec에서 작동하는지 확인하고 그들이 무엇을 하고 있는지 알아보세요.
@inproceedings { Shen2023NaturalSpeech2L ,
title = { NaturalSpeech 2: Latent Diffusion Models are Natural and Zero-Shot Speech and Singing Synthesizers } ,
author = { Kai Shen and Zeqian Ju and Xu Tan and Yanqing Liu and Yichong Leng and Lei He and Tao Qin and Sheng Zhao and Jiang Bian } ,
year = { 2023 }
}
@misc { shazeer2020glu ,
title = { GLU Variants Improve Transformer } ,
author = { Noam Shazeer } ,
year = { 2020 } ,
url = { https://arxiv.org/abs/2002.05202 }
}
@inproceedings { dao2022flashattention ,
title = { Flash{A}ttention: Fast and Memory-Efficient Exact Attention with {IO}-Awareness } ,
author = { Dao, Tri and Fu, Daniel Y. and Ermon, Stefano and Rudra, Atri and R{'e}, Christopher } ,
booktitle = { Advances in Neural Information Processing Systems } ,
year = { 2022 }
}
@article { Salimans2022ProgressiveDF ,
title = { Progressive Distillation for Fast Sampling of Diffusion Models } ,
author = { Tim Salimans and Jonathan Ho } ,
journal = { ArXiv } ,
year = { 2022 } ,
volume = { abs/2202.00512 }
}
@inproceedings { Hang2023EfficientDT ,
title = { Efficient Diffusion Training via Min-SNR Weighting Strategy } ,
author = { Tiankai Hang and Shuyang Gu and Chen Li and Jianmin Bao and Dong Chen and Han Hu and Xin Geng and Baining Guo } ,
year = { 2023 }
}
@article { Alayrac2022FlamingoAV ,
title = { Flamingo: a Visual Language Model for Few-Shot Learning } ,
author = { Jean-Baptiste Alayrac and Jeff Donahue and Pauline Luc and Antoine Miech and Iain Barr and Yana Hasson and Karel Lenc and Arthur Mensch and Katie Millican and Malcolm Reynolds and Roman Ring and Eliza Rutherford and Serkan Cabi and Tengda Han and Zhitao Gong and Sina Samangooei and Marianne Monteiro and Jacob Menick and Sebastian Borgeaud and Andy Brock and Aida Nematzadeh and Sahand Sharifzadeh and Mikolaj Binkowski and Ricardo Barreira and Oriol Vinyals and Andrew Zisserman and Karen Simonyan } ,
journal = { ArXiv } ,
year = { 2022 } ,
volume = { abs/2204.14198 }
}
@article { Badlani2021OneTA ,
title = { One TTS Alignment to Rule Them All } ,
author = { Rohan Badlani and Adrian Lancucki and Kevin J. Shih and Rafael Valle and Wei Ping and Bryan Catanzaro } ,
journal = { ICASSP 2022 - 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) } ,
year = { 2021 } ,
pages = { 6092-6096 } ,
url = { https://api.semanticscholar.org/CorpusID:237277973 }
}