|
import json |
|
import os |
|
import subprocess |
|
|
|
|
|
data = { |
|
"VCTK_p294": {"age": 33, "gender": "F", "accents": "American", "region": "San Francisco", "comments": ""}, |
|
"VCTK_p297": {"age": 20, "gender": "F", "accents": "American", "region": "New York", "comments": ""}, |
|
"VCTK_p299": {"age": 25, "gender": "F", "accents": "American", "region": "California", "comments": ""}, |
|
"VCTK_p300": {"age": 23, "gender": "F", "accents": "American", "region": "California", "comments": ""}, |
|
"VCTK_p301": {"age": 23, "gender": "F", "accents": "American", "region": "North Carolina", "comments": ""}, |
|
"VCTK_p305": {"age": 19, "gender": "F", "accents": "American", "region": "Philadelphia", "comments": ""}, |
|
"VCTK_p306": {"age": 21, "gender": "F", "accents": "American", "region": "New York", "comments": ""}, |
|
"VCTK_p308": {"age": 18, "gender": "F", "accents": "American", "region": "Alabama", "comments": ""}, |
|
"VCTK_p310": {"age": 21, "gender": "F", "accents": "American", "region": "Tennessee", "comments": ""}, |
|
"VCTK_p318": {"age": 32, "gender": "F", "accents": "American", "region": "Napa", "comments": ""}, |
|
"VCTK_p329": {"age": 23, "gender": "F", "accents": "American", "region": "America", "comments": ""}, |
|
"VCTK_p330": {"age": 26, "gender": "F", "accents": "American", "region": "America", "comments": ""}, |
|
"VCTK_p333": {"age": 19, "gender": "F", "accents": "American", "region": "Indiana", "comments": ""}, |
|
"VCTK_p361": {"age": 19, "gender": "F", "accents": "American", "region": "New Jersey", "comments": ""}, |
|
"VCTK_p362": {"age": 29, "gender": "F", "accents": "American", "region": "America", "comments": ""}, |
|
"VCTK_p339": {"age": 21, "gender": "F", "accents": "American", "region": "Pennsylvania", "comments": ""}, |
|
"VCTK_p341": {"age": 26, "gender": "F", "accents": "American", "region": "Ohio", "comments": ""} |
|
} |
|
|
|
|
|
|
|
json_data = json.dumps(data, indent=2) |
|
|
|
|
|
with open('speakers-log.json', 'w') as file: |
|
file.write(json_data) |
|
|
|
|
|
command = "tts --model_path checkpoint_85000.pth --config_path config.json --list_speaker_idxs | grep -vE '^(\s*\||\s*>|\s*$)'" |
|
output = subprocess.check_output(command, shell=True, text=True) |
|
|
|
|
|
speaker_indices = eval(output) |
|
|
|
|
|
with open('speakers-log.json', 'r') as file: |
|
speaker_ids = json.load(file) |
|
|
|
|
|
for speaker_idx in speaker_indices: |
|
|
|
speaker_id = speaker_idx |
|
|
|
|
|
|
|
if speaker_id in speaker_ids: |
|
speaker_id_json = speaker_ids[speaker_id] |
|
else: |
|
continue |
|
|
|
|
|
text = f"Hello, I am from {speaker_id_json['region']}. I hope that you will select my voice for your project. Thank you." |
|
|
|
if not os.path.exists("samples"): |
|
os.makedirs("samples") |
|
|
|
out_path = f"samples/{speaker_id}.wav" |
|
tts_command = f"tts --text \"{text}\" --model_path checkpoint_85000.pth --language_idx en --config_path config.json --speaker_idx \"{speaker_id}\" --out_path {out_path}" |
|
|
|
|
|
os.system(tts_command) |