Text-to-Speech
MLX
ONNX
Portuguese
tts
pt-br
brazilian-portuguese
small-model
quantized
apple-silicon
pingo
fargan
Instructions to use semfence/pingo-ptbr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use semfence/pingo-ptbr with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download semfence/pingo-ptbr --local-dir pingo-ptbr
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Download inference.py from semfence/pingo-ptbr: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/semfence/pingo-ptbr/resolve/main/inference.py
- Command line
-
hf download hf://semfence/pingo-ptbr/inference.py
-
curl -L -o inference.py https://huggingface.co/semfence/pingo-ptbr/resolve/main/inference.py
1.63 kB
| """Command-line entry point, same shape as PiVo's: | |
| python inference.py synthesize --voice F_s4 --text "Olá! Esta é a voz da SemFence." --output hello.wav | |
| python inference.py synthesize --model weights/pingo-ptbr-w96.bin --voice M_sm4 --text-file text.txt --speed 1.1 --output out.wav | |
| """ | |
| import argparse, sys | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(HERE / "pingo")) | |
| import soundfile as sf | |
| import speak | |
| def main(): | |
| ap = argparse.ArgumentParser(description="pingo-ptbr: Brazilian Portuguese text-to-speech in under 1 MB") | |
| sub = ap.add_subparsers(dest="command", required=True) | |
| s = sub.add_parser("synthesize", help="text -> wav (16 kHz, mono)") | |
| s.add_argument("--model", default=str(HERE / "weights" / "pingo-ptbr.bin")) | |
| s.add_argument("--voice", choices=list(speak.VOICES), default="F_s4") | |
| s.add_argument("--text"); s.add_argument("--text-file") | |
| s.add_argument("--speed", type=float, default=1.0, help="0.5 to 2.0; larger is faster") | |
| s.add_argument("--no-respelling", action="store_true", help="do not rewrite English words (see pingo/pronunciation.py)") | |
| s.add_argument("--output", "-o", default="out.wav") | |
| a = ap.parse_args() | |
| if bool(a.text) == bool(a.text_file): | |
| ap.error("pass exactly one of --text or --text-file") | |
| text = Path(a.text_file).read_text() if a.text_file else a.text | |
| audio = speak.speak(speak.Pingo(a.model), text, a.voice, a.speed, not a.no_respelling) | |
| sf.write(a.output, audio, speak.RATE) | |
| print(f"{a.output}: {len(audio) / speak.RATE:.2f} s") | |
| if __name__ == "__main__": | |
| main() | |