? Tensorflowtts

텐서 플로우에 대한 실시간 최신 언어 합성 2
? Tensorflowtts는 Tacotron-2, Melgan, Multiband-Melgan, Fastspeech, Fastspeech2 기반 Tensorflow 2와 같은 실시간 최신 음성 합성 아키텍처를 제공합니다. Tensorflow 2를 사용하면 속도를 높이고 실시기가 가짜 인식 및 가로를 사용하여 최적화를 최적화 할 수 있습니다. 시스템.
이 저장소는 우분투 18.04에서 다음과 같이 테스트됩니다.
다른 Tensorflow 버전은 작동하지만 아직 테스트되지 않아야합니다. 이 repo는 최신 안정적인 Tensorflow 버전으로 작업하려고합니다. Multigpu를 사용하려는 경우 Tensorflow 2.6.0을 교육에 설치하는 것이 좋습니다.
$ pip install TensorFlowTTS예제는 저장소에 포함되어 있지만 프레임 워크와 함께 배송되지 않습니다. 따라서 최신 버전의 예제를 실행하려면 아래 소스를 설치해야합니다.
$ git clone https://github.com/TensorSpeech/TensorFlowTTS.git
$ cd TensorFlowTTS
$ pip install .저장소 및 그 종속성을 업그레이드하려면 :
$ git pull
$ pip install --upgrade .Tensorflowtts는 현재 다음 아키텍처를 제공합니다.
또한 다음 논문에서 품질과 수렴 속도를 향상시키기위한 몇 가지 기술을 구현하고 있습니다.
여기에 유효한 세트의 오디오 샘플에서. Tacotron-2, Fastspeech, Melgan, Melgan.stft, Fastspeech2, Multiband_melgan
다음 형식으로 데이터 세트를 준비하십시오.
|- [NAME_DATASET]/
| |- metadata.csv
| |- wavs/
| |- file1.wav
| |- ...
여기서 metadata.csv 다음 형식을 갖습니다. id|transcription . 이것은 ljspeech와 같은 형식입니다. 다른 형식 데이터 세트가있는 경우 전처리 단계를 무시할 수 있습니다.
NAME_DATASET 은 예를 들어 [ljspeech/kss/baker/libritts/synpaflex] 여야합니다.
전처리에는 두 단계가 있습니다.
위의 단계를 재현하려면 :
tensorflow-tts-preprocess --rootdir ./[ljspeech/kss/baker/libritts/thorsten/synpaflex] --outdir ./dump_[ljspeech/kss/baker/libritts/thorsten/synpaflex] --config preprocess/[ljspeech/kss/baker/thorsten/synpaflex]_preprocess.yaml --dataset [ljspeech/kss/baker/libritts/thorsten/synpaflex]
tensorflow-tts-normalize --rootdir ./dump_[ljspeech/kss/baker/libritts/thorsten/synpaflex] --outdir ./dump_[ljspeech/kss/baker/libritts/thorsten/synpaflex] --config preprocess/[ljspeech/kss/baker/libritts/thorsten/synpaflex]_preprocess.yaml --dataset [ljspeech/kss/baker/libritts/thorsten/synpaflex]
현재 우리는 데이터 세트 인수에 대해 ljspeech , kss , baker , libritts , thorsten 및 synpaflex 만 지원합니다. 앞으로 더 많은 데이터 세트를 지원하려고합니다.
참고 : libritts Preprocessing을 실행하려면 먼저 예제/FastSpeech2_Libritts의 지침을 읽으십시오. 우리는 전처리를 실행하기 전에 먼저 그것을 재구성해야합니다.
참고 : synpaflex Preprocessing을 실행하려면 먼저 노트북 노트북/repay_synpaflex.ipynb를 실행하십시오. 우리는 전처리를 실행하기 전에 먼저 그것을 재구성해야합니다.
전처리 후 프로젝트 폴더의 구조는 다음과 같습니다.
|- [NAME_DATASET]/
| |- metadata.csv
| |- wav/
| |- file1.wav
| |- ...
|- dump_[ljspeech/kss/baker/libritts/thorsten]/
| |- train/
| |- ids/
| |- LJ001-0001-ids.npy
| |- ...
| |- raw-feats/
| |- LJ001-0001-raw-feats.npy
| |- ...
| |- raw-f0/
| |- LJ001-0001-raw-f0.npy
| |- ...
| |- raw-energies/
| |- LJ001-0001-raw-energy.npy
| |- ...
| |- norm-feats/
| |- LJ001-0001-norm-feats.npy
| |- ...
| |- wavs/
| |- LJ001-0001-wave.npy
| |- ...
| |- valid/
| |- ids/
| |- LJ001-0009-ids.npy
| |- ...
| |- raw-feats/
| |- LJ001-0009-raw-feats.npy
| |- ...
| |- raw-f0/
| |- LJ001-0001-raw-f0.npy
| |- ...
| |- raw-energies/
| |- LJ001-0001-raw-energy.npy
| |- ...
| |- norm-feats/
| |- LJ001-0009-norm-feats.npy
| |- ...
| |- wavs/
| |- LJ001-0009-wave.npy
| |- ...
| |- stats.npy
| |- stats_f0.npy
| |- stats_energy.npy
| |- train_utt_ids.npy
| |- valid_utt_ids.npy
|- examples/
| |- melgan/
| |- fastspeech/
| |- tacotron2/
| ...
stats.npy 훈련 분할 Mel 스펙트럼의 평균 및 STD를 포함합니다.stats_energy.npy 훈련 분할의 에너지 값의 평균과 STD를 포함합니다.stats_f0.npy 에는 훈련 분할의 F0 값의 평균과 STD가 포함됩니다.train_utt_ids.npy / valid_utt_ids.npy 각각 교육 및 유효성 발화 ID가 포함되어 있습니다. 우리는 각 입력 유형에 접미사 ( ids , raw-feats , raw-energy , raw-f0 , norm-feats 및 wave )를 사용합니다.
중요한 메모 :
dump 폴더의 최종 구조는 위의 구조를 따라 훈련 스크립트를 사용할 수 있거나 직접 수정할 수 있습니까? 다른 데이터 세트/언어로 모델을 처음부터 훈련시키는 방법을 알고 싶으시면 Example 디렉토리의 세부 사항을 참조하십시오.
tensorflow_tts/dataset/actract_dataset에서 추상 데이터 세트 클래스의 세부 구현. 지나치게 이해해야 할 몇 가지 기능이 있습니다.
중요한 메모 :
이 Abstract_dataset을 사용하는 몇 가지 예는 Tacotron_dataset.py, fastspeech_dataset.py, melgan_dataset.py, fastspeech2_dataset.py입니다.
Tensorflow_tts/Trainer/Base_trainer.py에서 Base_trainer의 세부 구현. SEQ2SeqbasedTrainer 및 GanBasedTrainer는 기반 트레이너에서 상속됩니다. 모든 트레이너는 단일/멀티 GPU를 모두 지원합니다. New_Trainer를 구현할 때 과도하게 내려야 하는 일부 기능이 있습니다.
이 repo의 모든 모델은 훈련 된 GanBasedTrainer (Train_Melgan.py, Train_Melgan_Stft.py, Train_Multiband_Melgan.py 참조) 및 SEQ2SeqBasedTrainer (Train_Tacotron2.py, Train_FastSpeech.py 참조)입니다.
노트북에서 각 모델을 추론하거나 Colab (영어), Colab (한국어), Colab (중국어), Colab (프랑스어), Colab (독일어)을 참조하십시오. 다음은 FastSpeech2 및 다중 대역 Melgan과의 End2end 추론에 대한 예제 코드입니다. 우리는 Huggingface Hub에 사방 된 모든 것을 업로드했습니다.
import numpy as np
import soundfile as sf
import yaml
import tensorflow as tf
from tensorflow_tts . inference import TFAutoModel
from tensorflow_tts . inference import AutoProcessor
# initialize fastspeech2 model.
fastspeech2 = TFAutoModel . from_pretrained ( "tensorspeech/tts-fastspeech2-ljspeech-en" )
# initialize mb_melgan model
mb_melgan = TFAutoModel . from_pretrained ( "tensorspeech/tts-mb_melgan-ljspeech-en" )
# inference
processor = AutoProcessor . from_pretrained ( "tensorspeech/tts-fastspeech2-ljspeech-en" )
input_ids = processor . text_to_sequence ( "Recent research at Harvard has shown meditating for as little as 8 weeks, can actually increase the grey matter in the parts of the brain responsible for emotional regulation, and learning." )
# fastspeech inference
mel_before , mel_after , duration_outputs , _ , _ = fastspeech2 . inference (
input_ids = tf . expand_dims ( tf . convert_to_tensor ( input_ids , dtype = tf . int32 ), 0 ),
speaker_ids = tf . convert_to_tensor ([ 0 ], dtype = tf . int32 ),
speed_ratios = tf . convert_to_tensor ([ 1.0 ], dtype = tf . float32 ),
f0_ratios = tf . convert_to_tensor ([ 1.0 ], dtype = tf . float32 ),
energy_ratios = tf . convert_to_tensor ([ 1.0 ], dtype = tf . float32 ),
)
# melgan inference
audio_before = mb_melgan . inference ( mel_before )[ 0 , :, 0 ]
audio_after = mb_melgan . inference ( mel_after )[ 0 , :, 0 ]
# save to file
sf . write ( './audio_before.wav' , audio_before , 22050 , "PCM_16" )
sf . write ( './audio_after.wav' , audio_after , 22050 , "PCM_16" )여기의 모든 모델은 Apache 2.0에 따라 라이센스가 부여됩니다
우리는 Melgan, Multi Band Melgan, Fastspeech 및 Tacotron에 대해 우리와 많은 것에 대해 논의한 Tomoki Hayashi에게 감사의 말씀을 전합니다. 이 프레임 워크 기반 그의 위대한 오픈 소스 평행선 Wavegan 프로젝트.