textconvertaudio / utils.py
vpduphuongtien's picture
Create utils.py
61031cd verified
raw
history blame contribute delete
585 Bytes
# =========================
# AI MC FORMAT
# =========================
def format_mc(text):
return f"""
🎙️ Kính thưa toàn thể nhân dân!
{text}
Trân trọng thông báo!
"""
# =========================
# SPLIT TEXT
# =========================
def split_text(text, max_len=2000):
chunks = []
while len(text) > max_len:
split_at = text.rfind(".", 0, max_len)
if split_at <= 0:
split_at = max_len
chunks.append(text[:split_at])
text = text[split_at:].strip()
if text:
chunks.append(text)
return chunks