Spaces:
Build error
Build error
Update txtsplit/txtsplit/__init__.py
Browse files- txtsplit/txtsplit/__init__.py +12 -15
txtsplit/txtsplit/__init__.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# alias that some libs might expect
|
| 15 |
-
split_text = split
|
|
|
|
| 1 |
+
# txtsplit shim for MeloTTS dependency
|
| 2 |
+
import re
|
| 3 |
+
from typing import List
|
| 4 |
+
|
| 5 |
+
def split(text: str) -> List[str]:
|
| 6 |
+
if not text:
|
| 7 |
+
return []
|
| 8 |
+
parts = re.split(r'(?<=[.!?])\s+', text.strip())
|
| 9 |
+
return [p.strip() for p in parts if p.strip()]
|
| 10 |
+
|
| 11 |
+
# alias some code may expect
|
| 12 |
+
split_text = split
|
|
|
|
|
|
|
|
|