Text-to-Speech
Transformers
English
Māori
abteex-ai-labs
aotearoa
audio
kokoro
local-first
lumynax
new-zealand
sovereign-ai
speech
tts
legacy
outdated
Instructions to use AbteeXAILab/lumynax-speech-kokoro-82m-tts with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbteeXAILab/lumynax-speech-kokoro-82m-tts with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="AbteeXAILab/lumynax-speech-kokoro-82m-tts")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AbteeXAILab/lumynax-speech-kokoro-82m-tts", device_map="auto") - Notebooks
- Google Colab
- Kaggle
docs(quickstart): load mirrored local weights (no upstream fetch)
Browse files- quickstart.py +60 -95
quickstart.py
CHANGED
|
@@ -1,95 +1,60 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
""
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
"
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
llm = Llama.from_pretrained(
|
| 62 |
-
repo_id=mirror, filename="*Q4_K_M*.gguf",
|
| 63 |
-
n_ctx=510,
|
| 64 |
-
n_gpu_layers=int(os.environ.get("N_GPU_LAYERS", "-1")), verbose=False,
|
| 65 |
-
)
|
| 66 |
-
def chat(user):
|
| 67 |
-
out = llm.create_chat_completion(messages=[
|
| 68 |
-
{"role": "system", "content": LUMYNAX_SYSTEM},
|
| 69 |
-
{"role": "user", "content": user},
|
| 70 |
-
], max_tokens=512, temperature=0.4)
|
| 71 |
-
return out["choices"][0]["message"]["content"]
|
| 72 |
-
if interactive:
|
| 73 |
-
while True:
|
| 74 |
-
try: q = input("you> ").strip()
|
| 75 |
-
except EOFError: break
|
| 76 |
-
if not q: break
|
| 77 |
-
print("lumynax> " + chat(q))
|
| 78 |
-
else:
|
| 79 |
-
print(chat(prompt))
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
def main():
|
| 83 |
-
p = argparse.ArgumentParser()
|
| 84 |
-
p.add_argument("--interactive", action="store_true")
|
| 85 |
-
p.add_argument("--prompt", default=DEMO_PROMPT)
|
| 86 |
-
p.add_argument("--gguf", action="store_true")
|
| 87 |
-
args = p.parse_args()
|
| 88 |
-
if args.gguf:
|
| 89 |
-
_run_gguf(args.prompt, args.interactive)
|
| 90 |
-
else:
|
| 91 |
-
_run_hf(args.prompt, args.interactive)
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
if __name__ == "__main__":
|
| 95 |
-
main()
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Lumynax Speech Kokoro 82M Tts — LumynaX quickstart (clone & run, multimodal safetensors).
|
| 3 |
+
|
| 4 |
+
Loads the local safetensors shards in this repo via transformers.
|
| 5 |
+
Requires significant VRAM (160+ GB VRAM).
|
| 6 |
+
|
| 7 |
+
Usage:
|
| 8 |
+
python quickstart.py --interactive
|
| 9 |
+
python quickstart.py --image foo.jpg --prompt "describe this"
|
| 10 |
+
"""
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
import argparse, os, sys
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
LUMYNAX_SYSTEM = "You are LumynaX, the AbteeX AI Labs assistant from Aotearoa New Zealand. Ko te marama te tuapapa. Answer with care; cite uncertainty; refuse unsafe asks."
|
| 16 |
+
DEMO_PROMPT = "Explain in 3 bullets why local-first AI matters for Aotearoa New Zealand."
|
| 17 |
+
HERE = Path(__file__).resolve().parent
|
| 18 |
+
|
| 19 |
+
def main():
|
| 20 |
+
import torch
|
| 21 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 22 |
+
p = argparse.ArgumentParser()
|
| 23 |
+
p.add_argument("--interactive", action="store_true")
|
| 24 |
+
p.add_argument("--prompt", default=DEMO_PROMPT)
|
| 25 |
+
p.add_argument("--image", default=None)
|
| 26 |
+
args = p.parse_args()
|
| 27 |
+
if not (HERE / "kokoro-v1_0.pth").exists():
|
| 28 |
+
print(f"[lumynax] weight index missing in {HERE}", file=sys.stderr)
|
| 29 |
+
print(f"[lumynax] run: hf download AbteeXAILab/lumynax-speech-kokoro-82m-tts --local-dir <dir> first.", file=sys.stderr)
|
| 30 |
+
sys.exit(2)
|
| 31 |
+
print(f"[lumynax] loading from local repo {HERE}")
|
| 32 |
+
processor = AutoProcessor.from_pretrained(str(HERE), trust_remote_code=True)
|
| 33 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 34 |
+
str(HERE), device_map="auto", torch_dtype="auto", trust_remote_code=True
|
| 35 |
+
)
|
| 36 |
+
def chat(user, img):
|
| 37 |
+
content = [{"type":"text","text":user}]
|
| 38 |
+
if img: content.insert(0, {"type":"image","url":img})
|
| 39 |
+
messages = [
|
| 40 |
+
{"role":"system","content":[{"type":"text","text":LUMYNAX_SYSTEM}]},
|
| 41 |
+
{"role":"user","content":content},
|
| 42 |
+
]
|
| 43 |
+
inputs = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=True,
|
| 44 |
+
return_dict=True, return_tensors="pt").to(model.device)
|
| 45 |
+
out = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.4)
|
| 46 |
+
return processor.batch_decode(out[:, inputs["input_ids"].shape[-1]:], skip_special_tokens=True)[0]
|
| 47 |
+
if args.interactive:
|
| 48 |
+
print("[lumynax] interactive — '/img <path>' attaches, empty line exits.")
|
| 49 |
+
pending = None
|
| 50 |
+
while True:
|
| 51 |
+
try: q = input("you> ").strip()
|
| 52 |
+
except EOFError: break
|
| 53 |
+
if not q: break
|
| 54 |
+
if q.startswith("/img "): pending = q[5:].strip(); print(f"[lumynax] attached: {pending}"); continue
|
| 55 |
+
print("lumynax> " + chat(q, pending)); pending = None
|
| 56 |
+
else:
|
| 57 |
+
print(chat(args.prompt, args.image))
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|