mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-10-07 15:19:59 +08:00
增加了auto切分
This commit is contained in:
parent
ed3abd5fd5
commit
c89f4511da
@ -118,6 +118,39 @@ def cut5(inp):
|
||||
opt = "\n".join(mergeitems)
|
||||
return opt
|
||||
|
||||
@register_method("auto_cut")
|
||||
def auto_cut(inp):
|
||||
# if not re.search(r'[^\w\s]', inp[-1]):
|
||||
# inp += '。'
|
||||
inp = inp.strip("\n")
|
||||
|
||||
split_punds = r'[?!。?!~:]'
|
||||
if inp[-1] not in split_punds:
|
||||
inp+="。"
|
||||
items = re.split(f'({split_punds})', inp)
|
||||
items = ["".join(group) for group in zip(items[::2], items[1::2])]
|
||||
|
||||
def process_commas(text):
|
||||
|
||||
separators = [',', ',', '、', '——', '…']
|
||||
count = 0
|
||||
processed_text = ""
|
||||
for char in text:
|
||||
processed_text += char
|
||||
if char in separators:
|
||||
if count > 12:
|
||||
processed_text += '\n'
|
||||
count = 0
|
||||
else:
|
||||
count += 1 # 对于非分隔符字符,增加计数
|
||||
return processed_text
|
||||
|
||||
final_items=[process_commas(item) for item in items]
|
||||
final_items = [item for item in final_items if item.strip()]
|
||||
|
||||
return "\n".join(final_items)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 39118a4e07c66690e33be6ec8a90652b7dd2a432
|
||||
Subproject commit 5c8314db790f57c488c2d69f129c475440879ba6
|
Loading…
x
Reference in New Issue
Block a user