voice-changer/demo/mods/Trainer_Speaker.py

15 lines
551 B
Python
Raw Normal View History

2022-11-08 13:00:47 +03:00
import shutil
from mods.Trainer_MultiSpeakerSetting import MULTI_SPEAKER_SETTING_PATH
def mod_delete_speaker(speaker:str):
2022-12-09 06:52:27 +03:00
shutil.rmtree(f"MMVC_Trainer/dataset/textful/{speaker}")
2022-11-08 13:00:47 +03:00
with open(MULTI_SPEAKER_SETTING_PATH, "r") as f:
setting = f.readlines()
filtered = filter(lambda x: x.startswith(f"{speaker}|")==False, setting)
with open(MULTI_SPEAKER_SETTING_PATH, "w") as f:
f.writelines(list(filtered))
f.flush()
f.close()
return {"Speaker deleted": f"{speaker}"}