ワンクリックで
huggingface-text-to-speech
Generate speech audio from text using Hugging Face models (Transformers pipeline), CLI script, and WAV/MP3 export.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generate speech audio from text using Hugging Face models (Transformers pipeline), CLI script, and WAV/MP3 export.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | huggingface-text-to-speech |
| description | Generate speech audio from text using Hugging Face models (Transformers pipeline), CLI script, and WAV/MP3 export. |
| metadata | {"tags":"tts, huggingface, transformers, audio, speech"} |
Use this skill when you need to synthesize voice audio from text with a model hosted on the Hugging Face Hub, run inference locally with the transformers text-to-speech pipeline, and save WAV (default) or MP3 (optional).
uv python install 3.12) or use one already on PATH.torch in the same uv pip install line as below.uv venv
uv pip install "transformers[torch]" torch soundfile accelerate
Models download from the Hub automatically on first inference (cached under the Hugging Face cache).
MP3 output additionally requires pydub and a system FFmpeg binary on PATH:
uv pip install pydub
If you only need WAV, FFmpeg is not required.
hf_tts.pyThe project provides a command-line helper: hf_tts.py.
It builds a pipeline(task="text-to-speech", model=...) (alias of the text-to-audio task), runs your text through the model, and writes:
.wav — always supported (PCM via soundfile)..mp3 — only if pydub and FFmpeg are available; otherwise use .wav or convert offline.Run with uv run so the local .venv from setup is used (from skills/text-to-speech/):
uv run python hf_tts.py --model facebook/mms-tts-eng --text "Hello, world." -o speech.wav
Read long scripts from a file:
uv run python hf_tts.py --model facebook/mms-tts-eng --text-file narration.txt -o out.wav
Use GPU and half precision when appropriate:
uv run python hf_tts.py --model facebook/mms-tts-eng --text "Hello" -o out.wav --device cuda:0 --dtype float16
Models that use custom code on the Hub need the flag:
uv run python hf_tts.py --model suno/bark --text "Hello" -o bark.wav --trust-remote-code --pipe-kwargs "{\"voice_preset\":\"v2/en_speaker_6\"}"
| Argument | Description |
|---|---|
--model | Required. Hugging Face model id (e.g. facebook/mms-tts-eng). |
--text / -t | Input string (mutually exclusive with --text-file). |
--text-file | Path to a UTF-8 text file. |
--output / -o | Output path; extension .wav or .mp3 (default: tts_output.wav). |
--device | auto (GPU if available else CPU), cpu, cuda, cuda:0, etc. |
--dtype | float32, float16, or bfloat16. |
--trust-remote-code | Set when the model repo requires executing custom modeling code. |
--seed | Optional; passed to transformers.set_seed. |
--forward-params | JSON object for pipe(text, forward_params=...). Use when the docs show forward_params (e.g. SpeechT5 speaker_embeddings — tensors cannot be passed from JSON; use a tiny custom script for those). |
--pipe-kwargs | JSON object merged into the pipeline __call__ (e.g. Bark voice_preset). |
--pipeline-kwargs | JSON object merged into pipeline(...) (e.g. extra model_kwargs). |
No separate download step is required: the first pipeline load calls from_pretrained under the hood and caches weights in the Hugging Face cache (usually ~/.cache/huggingface or %USERPROFILE%\.cache\huggingface on Windows). Re-runs reuse the cache unless you change the model id or revision.
facebook/mms-tts-eng, etc.) works well with the default pipeline and no extra objects.suno/bark) typically needs --trust-remote-code and optional voice_preset via --pipe-kwargs (see example above).pipeline(...) — that is model-specific; use --pipeline-kwargs only if the values are JSON-serializable, or extend hf_tts.py locally for that checkpoint.The pipeline returns a dict with audio (waveform) and sampling_rate, which the script writes to disk — the same pattern documented for VITS/MMS-style usage in Transformers.
--forward-params with tensors (e.g. SpeechT5 speaker embeddings) cannot be expressed as plain JSON; load embeddings in Python and call pipe(text, forward_params={"speaker_embeddings": ...}) in a short custom script.