2023-08-02 21:53:35 +00:00
|
|
|
import os
|
|
|
|
import json
|
|
|
|
|
2023-08-26 15:21:12 +00:00
|
|
|
input_dataset = "LibriTTS_R"
|
|
|
|
output_dataset = "LibriTTS-Train"
|
|
|
|
|
|
|
|
for dataset_name in os.listdir(f'./{input_dataset}/'):
|
|
|
|
if not os.path.isdir(f'./{input_dataset}/{dataset_name}/'):
|
2023-08-02 21:53:35 +00:00
|
|
|
continue
|
2023-08-26 15:21:12 +00:00
|
|
|
for speaker_id in os.listdir(f'./{input_dataset}/{dataset_name}/'):
|
|
|
|
if not os.path.isdir(f'./{input_dataset}/{dataset_name}/{speaker_id}'):
|
2023-08-02 21:53:35 +00:00
|
|
|
continue
|
2023-08-26 15:21:12 +00:00
|
|
|
for book_id in os.listdir(f'./{input_dataset}/{dataset_name}/{speaker_id}'):
|
|
|
|
if not os.path.isdir(f'./{input_dataset}/{dataset_name}/{speaker_id}/{book_id}'):
|
2023-08-02 21:53:35 +00:00
|
|
|
continue
|
2023-08-26 15:21:12 +00:00
|
|
|
for filename in os.listdir(f'./{input_dataset}/{dataset_name}/{speaker_id}/{book_id}'):
|
|
|
|
if filename[-4:] != ".wav":
|
2023-08-02 21:53:35 +00:00
|
|
|
continue
|
|
|
|
|
2023-08-26 15:21:12 +00:00
|
|
|
os.makedirs(f'./{output_dataset}/{speaker_id}/', exist_ok=True)
|
|
|
|
os.rename(f'./{input_dataset}/{dataset_name}/{speaker_id}/{book_id}/{filename}', f'./{output_dataset}/{speaker_id}/{filename}')
|