voice-changer/demo/mods/Trainer_Speaker_Voices.py

22 lines
844 B
Python
Raw Normal View History

2022-11-08 13:00:47 +03:00
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
from trainer_mods.files import get_file_list
import os
def mod_get_speaker_voices(speaker:str):
2022-12-09 06:52:27 +03:00
voices = get_file_list(f'MMVC_Trainer/dataset/textful/{speaker}/wav/*.wav')
2022-11-08 13:00:47 +03:00
2022-12-09 06:52:27 +03:00
texts = get_file_list(f'MMVC_Trainer/dataset/textful/{speaker}/text/*.txt')
2022-11-08 13:00:47 +03:00
2022-12-09 06:52:27 +03:00
readable_texts = get_file_list(f'MMVC_Trainer/dataset/textful/{speaker}/readable_text/*.txt')
2022-11-08 13:00:47 +03:00
items = voices
items.extend(texts)
items.extend(readable_texts)
items = [ os.path.splitext(os.path.basename(x))[0] for x in items]
items = sorted(set(items))
data = {
"voices":items
}
json_compatible_item_data = jsonable_encoder(data)
return JSONResponse(content=json_compatible_item_data)