youtube_tts_data_generator
Youtube Speech Data Generator
A python library to generate speech dataset. Youtube Speech Data Generator also takes care of almost all your speech data preprocessing needed to build a speech dataset along with their transcriptions making sure it follows a directory structure followed by most of the text-to-speech architectures.
Make sure ffmpeg is installed and is set to the system path.
$ pip install youtube-tts-data-generatorfrom youtube_tts_data_generator import YTSpeechDataGenerator
# First create a YTSpeechDataGenerator instance:
generator = YTSpeechDataGenerator(dataset_name='elon')
# Now create a '.txt' file that contains a list of YouTube videos that contains speeches.
# NOTE - Make sure you choose videos with subtitles.
generator.prepare_dataset('links.txt')
# The above will take care about creating your dataset, creating a metadata file and trimming silence from the audios.Initializing the generator:
generator = YTSpeechDataGenerator(dataset_name='your_dataset',lang='en')
├───your_dataset
│ ├───txts
│ └───wavs
└───your_dataset_prep
├───concatenated
├───downloaded
└───split
{
"your_dataset1.wav": "This is an example text",
"your_dataset2.wav": "This is an another example text",
}
generator.get_available_langs()Methods:
filename,subtitle,trim_min_begin,trim_min_end
audio.wav,subtitle.srt,0,0
audio2.wav,subtitle.vtt,5,6
generator.download('links.txt')generator.split_audios()generator.concat_audios()generator.finalize_dataset(min_audio_length=6)generator.get_available_langs()generator.get_total_audio_length()generator.prepare_dataset(links_txt='links.txt', download_youtube_data=True, min_audio_length=6)Once the dataset has been created, the structure under 'your_dataset' directory should look like:
your_dataset
├───txts
│ ├───your_dataset1.txt
│ └───your_dataset2.txt
├───wavs
│ ├───your_dataset1.wav
│ └───your_dataset2.wav
└───metadata.csv/alignment.json
NOTE - audio.py is highly based on Real Time Voice Cloning
SRT to JSON
Read more about the library here