Add error handing to emotion RVC mode

This commit is contained in:
Cohee
2024-08-28 20:43:20 +03:00
parent 3d40acaacc
commit edee9dcd85

View File

@@ -180,35 +180,40 @@ def rvc_process_audio():
# HACK: emotion mode EXPERIMENTAL
if classification_mode:
print(DEBUG_PREFIX,"EXPERIMENT MODE: emotions")
try:
print(DEBUG_PREFIX,"EXPERIMENT MODE: emotions")
print("> Searching overide code ($emotion$)")
emotion = None
for code in ["anger","fear", "joy","love","sadness","surprise"]:
if "$"+code+"$" in parameters["text"]:
print(" > Overide detected:",code)
emotion = code
parameters["text"] = parameters["text"].replace("$"+code+"$","")
print(parameters["text"])
break
print("> Searching overide code ($emotion$)")
emotion = None
for code in ["anger","fear", "joy","love","sadness","surprise"]:
if "$"+code+"$" in parameters["text"]:
print(" > Overide detected:",code)
emotion = code
parameters["text"] = parameters["text"].replace("$"+code+"$","")
print(parameters["text"])
break
if emotion is None:
print("> calling text classification pipeline")
emotions_score = classify_module.classify_text_emotion(parameters["text"])
if emotion is None:
print("> calling text classification pipeline")
emotions_score = classify_module.classify_text_emotion(parameters["text"])
print(" > ",emotions_score)
emotion = emotions_score[0]["label"]
print(" > Selected:", emotion)
print(" > ",emotions_score)
emotion = emotions_score[0]["label"]
print(" > Selected:", emotion)
model_path = folder_path+emotion+".pth"
index_path = folder_path+emotion+".index"
model_path = folder_path+emotion+".pth"
index_path = folder_path+emotion+".index"
if not os.path.exists(model_path):
print(" > WARNING emotion model pth not found:",model_path," will try loading default")
if not os.path.exists(model_path):
print(" > WARNING emotion model pth not found:",model_path," will try loading default")
model_path = None
if not os.path.exists(index_path):
print(" > WARNING emotion model index not found:",index_path)
index_path = None
except Exception as e:
print(f" > ERROR: emotion mode failed {str(e)}")
model_path = None
if not os.path.exists(index_path):
print(" > WARNING emotion model index not found:",index_path)
index_path = None
if model_path is None: