# Run Lahgtna Egyptian-Arabic TTS on Google Colab Generate Egyptian-Arabic speech with **v3** (multi-voice, non-diacritized) on a **free Colab GPU**. Copy each cell into a Colab notebook (set **Runtime → Change runtime type → T4 GPU** first). > The model repos are **private**, so you'll log in with your Hugging Face token (a **read** token > from ). --- ### 1) Install ```python !pip install -q omnivoice catt-tashkeel num2words soundfile ``` ### 2) Log in to Hugging Face (needed for the private repo) ```python from huggingface_hub import login login() # paste a READ token when prompted ``` ### 3) Load the model + the bundled reference voice ```python import torch from omnivoice.models.omnivoice import OmniVoice from huggingface_hub import hf_hub_download REPO = "ehabnegm/lahgtna-omnivoice-egyptian-v3" model = OmniVoice.from_pretrained(REPO, device_map="cuda", dtype=torch.float16) ref_audio = hf_hub_download(REPO, "reference.wav") # narrator voice clip ref_text = "كان العمل التطوعي واللي لما تفتح الباب بس ليه الناس" ``` ### 4) Text front-end + long-form helper (chunk → no drift) ```python import re, numpy as np, soundfile as sf from num2words import num2words _DIGITS = str.maketrans("٠١٢٣٤٥٦٧٨٩", "0123456789") HARAKAT = re.compile(r"[ً-ْٰـ]") def prep(t): # numbers -> words, strip diacritics/English t = t.translate(_DIGITS) t = re.sub(r"\d+", lambda m: " " + num2words(int(m.group()), lang="ar") + " ", t) t = re.sub(r"[A-Za-z]+", " ", t) t = HARAKAT.sub("", t).replace("ى", "ي") return re.sub(r"\s+", " ", t).strip() def chunks(t): # split into clauses out, cur = [], "" for p in re.split(r"([،؛\.؟!\n]+)", t): cur += p if re.search(r"[،؛\.؟!\n]", p): if cur.strip(): out.append(cur.strip()) cur = "" if cur.strip(): out.append(cur.strip()) return out or [t] def synth(text, num_step=16): # ALWAYS chunk long text parts = [model.generate(text=prep(c), language="arz", ref_audio=ref_audio, ref_text=ref_text, num_step=num_step)[0] for c in chunks(text) if prep(c)] return np.concatenate(parts) ``` ### 5) Generate & play ```python from IPython.display import Audio text = "أهلاً بحضرتك، معاك المساعد الذكي. اتفضل قوللي محتاج إيه، وأنا تحت أمرك." audio = synth(text) sf.write("out.wav", audio, 24000) Audio("out.wav") ``` ### 6) Long paragraph (works thanks to chunking) ```python long_text = ("في السنين الأخيرة، بقى الذكاء الاصطناعي جزء أساسي من حياتنا. " "بس السؤال المهم، هو إحنا فاهمين التكنولوجيا دي كويس، ولا بس بنستخدمها وخلاص؟ " "خليني أوضّحلك حاجة مهمة، الذكاء الاصطناعي مش سحر، هو نماذج بتتعلم من البيانات.") sf.write("long.wav", synth(long_text), 24000) Audio("long.wav") ``` --- ## Tips - **Speed:** lower `num_step` → faster first audio (8 ≈ 0.5 s to first chunk, 4 ≈ 0.3 s) with a small quality trade-off. - **Voice:** swap `reference.wav` for any 5–10 s clean clip of the voice you want to clone (and set `ref_text` to its transcript). - **Language id:** always `language="arz"` (Egyptian Arabic). - **Rule:** never send more than ~one sentence to a single `generate()` call — always chunk (the `synth()` helper does it for you). - Other models: `ehabnegm/lahgtna-omnivoice-egyptian` (v1), `-v2` (v2). For v1/v2 keep diacritics (use the `catt-tashkeel` diacritizer) instead of the `HARAKAT.sub` stripping above.