Fix bug: wrong order or custom phoneme

This commit is contained in:
fondoger 2025-04-04 23:25:24 +08:00
parent 8c08655a08
commit a1e686cccb

View file

@ -100,16 +100,14 @@ def get_sentence_info(text: str, custom_phenomes_list: Dict[str, str]) -> List[T
""" """
sentences = re.split(r"([.!?;:])(?=\s|$)", text) sentences = re.split(r"([.!?;:])(?=\s|$)", text)
phoneme_length, min_value = len(custom_phenomes_list), 0
results = [] results = []
for i in range(0, len(sentences), 2): for i in range(0, len(sentences), 2):
sentence = sentences[i].strip() sentence = sentences[i].strip()
for replaced in range(min_value, phoneme_length): for key in list(custom_phenomes_list.keys()):
current_id = f"</|custom_phonemes_{replaced}|/>" if key in sentence:
if current_id in sentence: sentence = sentence.replace(key, custom_phenomes_list[key])
sentence = sentence.replace(current_id, custom_phenomes_list.pop(current_id)) del custom_phenomes_list[key]
min_value += 1
# Handle silence tags # Handle silence tags
# Eg: "This is a test sentence, [silent](/1s/) with silence for one second." # Eg: "This is a test sentence, [silent](/1s/) with silence for one second."