mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-04-13 09:39:17 +00:00
Fix bug: wrong order or custom phoneme
This commit is contained in:
parent
8c08655a08
commit
a1e686cccb
1 changed files with 4 additions and 6 deletions
|
@ -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."
|
||||||
|
|
Loading…
Add table
Reference in a new issue