Text-to-Speech
ONNX
GGUF
Chinese
English
onnxruntime
tts
on-device
jetson
telephony
vits
mb-istft-vits
multi-speaker
mandarin
taiwanese-mandarin
imatrix
conversational
Instructions to use Luigi/PrimeTTS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use Luigi/PrimeTTS with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Luigi/PrimeTTS", filename="streaming_llm/gemma270m_it_q8.gguf", )
llm.create_chat_completion( messages = "\"The answer to the universe is 42\"" )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Luigi/PrimeTTS with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Luigi/PrimeTTS:F32 # Run inference directly in the terminal: llama cli -hf Luigi/PrimeTTS:F32
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Luigi/PrimeTTS:F32 # Run inference directly in the terminal: llama cli -hf Luigi/PrimeTTS:F32
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Luigi/PrimeTTS:F32 # Run inference directly in the terminal: ./llama-cli -hf Luigi/PrimeTTS:F32
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Luigi/PrimeTTS:F32 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Luigi/PrimeTTS:F32
Use Docker
docker model run hf.co/Luigi/PrimeTTS:F32
- LM Studio
- Jan
- Ollama
How to use Luigi/PrimeTTS with Ollama:
ollama run hf.co/Luigi/PrimeTTS:F32
- Unsloth Studio
How to use Luigi/PrimeTTS with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Luigi/PrimeTTS to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Luigi/PrimeTTS to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Luigi/PrimeTTS to start chatting
- Atomic Chat new
- Docker Model Runner
How to use Luigi/PrimeTTS with Docker Model Runner:
docker model run hf.co/Luigi/PrimeTTS:F32
- Lemonade
How to use Luigi/PrimeTTS with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Luigi/PrimeTTS:F32
Run and chat with the model
lemonade run user.PrimeTTS-F32
List all available models
lemonade list
| #!/usr/bin/env python3 | |
| """Long-text synthesis with automatic chunking. The acoustic model degrades past ~max_frames | |
| (1400 ~ 15s) because the absolute positional encoding saturates -> garbled syllables in the back | |
| half of long utterances. Fix: split text at punctuation into clauses, greedily pack clauses so each | |
| chunk's PREDICTED frame count stays under a safe budget, synth each chunk, concatenate with a short | |
| gap. No retrain. Same pipeline as synth_from_text.py.""" | |
| import argparse, json, re, sys | |
| from pathlib import Path | |
| sys.path.insert(0, "/home/luigi/jetson-tts/mossnano/zhtw8k") | |
| import numpy as np, soundfile as sf, onnxruntime as ort | |
| import frontend_bopomofo as F | |
| from synth_from_text import host_regulate | |
| BN = ["frames", "frame_meta", "local_ctx_raw", "abs_pos", "pitch_frame", "frame_mask"] | |
| # split AFTER these (keep the delimiter with the preceding clause for prosody) | |
| SPLIT_RE = re.compile(r'(?<=[。!?;;!?\n,,、])') | |
| def clauses(text): | |
| parts = [p for p in SPLIT_RE.split(text) if p.strip()] | |
| return parts or [text] | |
| class LongSynth: | |
| def __init__(self, onnx_dir, frame_budget=1100, gap_ms=70): | |
| self.meta = json.load(open(f"{onnx_dir}/meta.json")) | |
| so = ort.SessionOptions(); so.intra_op_num_threads = 4 | |
| self.sA = ort.InferenceSession(f"{onnx_dir}/acoustic_encoder.onnx", so, providers=["CPUExecutionProvider"]) | |
| self.sB = ort.InferenceSession(f"{onnx_dir}/acoustic_decoder.onnx", so, providers=["CPUExecutionProvider"]) | |
| self.sV = ort.InferenceSession(f"{onnx_dir}/vocoder.onnx", so, providers=["CPUExecutionProvider"]) | |
| self.sr = self.meta["sample_rate"] | |
| self.budget = frame_budget | |
| self.gap = np.zeros(int(self.sr * gap_ms / 1000), np.float32) | |
| def _encode(self, text): | |
| o = F.text_to_ids(text) | |
| if not o["phone_ids"]: | |
| return None | |
| phone = np.array([o["phone_ids"]], np.int64); tone = np.array([o["tone_ids"]], np.int64) | |
| lang = np.array([o["lang_ids"]], np.int64); spk = np.zeros(1, np.int64) | |
| cond, dur, pitch = self.sA.run(None, {"phone": phone, "tone": tone, "lang": lang, "speaker": spk}) | |
| return cond, dur, pitch | |
| def _decode(self, enc): | |
| cond, dur, pitch = enc | |
| reg = host_regulate(cond, dur, pitch, self.meta["abs_frame_bins"], self.meta["max_frames"]) | |
| feeds = {n: (reg[n].astype(np.float32) if reg[n].dtype != bool else reg[n]) for n in BN} | |
| feeds["abs_pos"] = reg["abs_pos"].astype(np.int64) | |
| mel = self.sB.run(None, feeds)[0] | |
| return self.sV.run(None, {"mel": mel.astype(np.float32)})[0].reshape(-1) | |
| def pack(self, text): | |
| """Greedily pack clauses into chunks whose predicted frame total <= budget.""" | |
| chunks, cur, cur_frames = [], "", 0 | |
| for cl in clauses(text): | |
| enc = self._encode(cl) | |
| f = int(enc[1].sum()) if enc is not None else 0 | |
| if cur and cur_frames + f > self.budget: | |
| chunks.append(cur); cur, cur_frames = "", 0 | |
| cur += cl; cur_frames += f | |
| # a single clause already over budget: still emit it alone (rare) | |
| if cur_frames > self.budget and cur == cl: | |
| chunks.append(cur); cur, cur_frames = "", 0 | |
| if cur: | |
| chunks.append(cur) | |
| return chunks | |
| def synth(self, text): | |
| chs = self.pack(text) | |
| wavs = [] | |
| for i, c in enumerate(chs): | |
| enc = self._encode(c) | |
| if enc is None: | |
| continue | |
| wavs.append(self._decode(enc)) | |
| if i < len(chs) - 1: | |
| wavs.append(self.gap) | |
| return (np.concatenate(wavs) if wavs else np.zeros(1, np.float32)), chs | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--onnx-dir", required=True) | |
| ap.add_argument("--out-dir", required=True) | |
| ap.add_argument("--texts", required=True, help="jsonl with {id,text}") | |
| ap.add_argument("--frame-budget", type=int, default=1100) | |
| ap.add_argument("--gap-ms", type=int, default=70) | |
| a = ap.parse_args() | |
| ls = LongSynth(a.onnx_dir, a.frame_budget, a.gap_ms) | |
| Path(a.out_dir).mkdir(parents=True, exist_ok=True) | |
| man = open(f"{a.out_dir}/synth.jsonl", "w") | |
| for r in (json.loads(l) for l in open(a.texts) if l.strip()): | |
| wav, chs = ls.synth(r["text"]) | |
| wp = f"{a.out_dir}/{r['id']}.wav"; sf.write(wp, wav, ls.sr) | |
| man.write(json.dumps({"id": r["id"], "text": r["text"], "wav": wp, "chunks": len(chs), | |
| "dur": round(len(wav)/ls.sr, 2)}, ensure_ascii=False) + "\n") | |
| print(f" {r['id']}: {len(chs)} chunks, {len(wav)/ls.sr:.1f}s -> {wp}") | |
| man.close() | |
| print(f"DONE synth_long -> {a.out_dir}/synth.jsonl") | |
| if __name__ == "__main__": | |
| main() | |