当前位置: 首页 > Skill >

Truly Local Piper Multilang TTS (secure)

Truly Local Piper Multilang TTS (secure)

Truly Local Piper Multilang TTS (secure)

本地离线文字转语音,使用Piper TTS。自包含设置,自动语言检测,每次调用可选声音。支持任意语言扩展。写入...

1.1.0 2026.11.25 954
获取Skill文件查看使用说明
作 者:沈川 许可证: 更新时间:2026.11.25
本文目录展开

local-piper-tts-multilang-secure

Description

Local (offline) text-to-speech via Piper.

Purpose: generate audio files (OGG/Opus by default) from text, fully offline. No sending is performed by the skill — sending is handled by the agent after the file is ready.

Features

  • Fully offline (no API keys)
  • Self-contained setup via setup() — installs Piper into an isolated venv, no system-wide changes
  • Automatic language detection for 20+ languages with English as default
  • Per-call voice selection via voice parameter
  • On-demand voice download via downloadVoices() — no models bundled, choose what you need
  • Voice removal via removeVoice() — clean up voices you no longer want
  • Extensible: add any language by installing a Piper .onnx model
  • Writes outputs into OpenClaw workspace

First-run flow — full agent procedure

Follow this sequence exactly when the user asks to use TTS for the first time in a setup context.

Step 1 — check status

const s = await status();

Step 2 — install Piper if needed

If s.stage is not-setup or no-piper:

  • Tell the user: "To use local TTS I need to install piper-tts into the skill's venv (~30 seconds, one-time). OK to proceed?"
  • Wait for confirmation, then call setup().
  • If setup returns a step containing "WARNING: espeak-ng not found", relay the warning and install instructions to the user.
  • Call status() again after setup completes.

Step 3 — offer voice download if no models present

If s.stage is no-model (Piper installed but no .onnx files):

3a. Offer English defaults: Explain that two English voices are available as defaults (~65 MB each):

  • en_US-ryan-medium — male, American
  • en_US-amy-medium — female, American

Ask which they want, or both: "Which English voice(s) should I download? Ryan (male), Amy (female), or both?"

3b. Ask about other languages: After the English choice, ask: "Do you need any other languages? For example German, French, Spanish, Polish, Italian, Portuguese, Russian… Just tell me and I'll check what's available."

If the user names a language, look up the available models at https://github.com/rhasspy/piper/blob/master/VOICES.md and list the options. Download whatever the user picks using the same downloadVoices() call.

3c. Download everything at once:

const result = await downloadVoices(['en_US-ryan-medium', 'en_US-amy-medium', /* + any others */]);
// result.downloaded — succeeded
// result.failed     — [{stem, error}] if any failed

Each voice requires internet access. Download takes ~1–2 min per voice on a typical connection.

If any downloads fail:

  • Check internet connectivity
  • Verify the stem exists at https://github.com/rhasspy/piper/blob/master/VOICES.md
  • Offer to retry

Step 4 — play samples so the user can choose

After downloading, generate a short audio sample for each downloaded voice and send it to the user.

For each voice, use a greeting in the voice's language:

  • English: "Hello, I'm [name]. How can I help you today?"
  • German: "Hallo, ich heiße [Name]. Wie kann ich Ihnen helfen?"
  • French: "Bonjour, je m'appelle [prénom]. Comment puis-je vous aider?"
  • Spanish: "Hola, me llamo [nombre]. ¿Cómo puedo ayudarte?"
  • Polish: "Cześć, mam na imię [imię]. Jak mogę Ci pomóc?"
  • Italian: "Ciao, mi chiamo [nome]. Come posso aiutarti?"
  • Portuguese: "Olá, meu nome é [nome]. Como posso ajudar?"
  • Russian: "Привет, меня зовут [имя]. Чем могу помочь?"
  • For other languages: use an equivalent native greeting.

Replace [name] with the voice name (e.g. Ryan, Amy, Thorsten).

const sample = await tts({ text: 'Hello, I'm Ryan. How can I help you today?', voice: 'en_US-ryan-medium' });
// send sample.path to the user as a voice message

Send all samples, then ask: "Which voice do you prefer? Or shall I download a different one?"

Step 5 — choose speech speed

After the user picks a voice, ask: "How fast should I speak? Normal is 100%. Some options: 125% (faster), 115% (slightly faster), 100% (normal), 80% (slower) — or tell me a percentage."

Always present speed as a percentage to the user. Never mention lengthScale directly.

lengthScale is the internal duration multiplier — lower = faster. To convert: lengthScale = 1 / (speed% / 100). Examples:

  • 125% speed → lengthScale 0.8
  • 115% speed → lengthScale 0.87
  • 100% speed → lengthScale 1.0 (default)
  • 80% speed → lengthScale 1.25

Generate a short sample at the chosen speed so the user can hear the difference:

const sample = await tts({ text: 'This is how I sound at this speed.', voice: 'chosen-voice', lengthScale: 0.8 });
// send sample.path to the user

Confirm with the user, then offer to save it permanently: "Should I save this as your default speed? It'll be used automatically every session."

If the user agrees:

await saveConfig({ lengthScale: 0.8 });

Once saved, tts() reads it from config.json in the skill directory automatically — no need to pass lengthScale on every call.

Step 6 — note the preferred voice and speed

Once confirmed, remember both voice and lengthScale for the session. Pass them to every subsequent tts() call unless the user asks to change them.

Before first use — always call status()

Always call status() before the first tts() call in a session to determine what is needed.

stage Meaning What to do
ready Fully installed, at least one voice model present Proceed with tts()
not-setup Piper not installed Ask user for confirmation, then call setup()
no-piper Venv exists but piper binary missing Ask user for confirmation, then call setup()
no-model Piper installed but no voice model downloaded Follow Steps 3–5 of first-run flow above

IMPORTANT: Always ask the user for confirmation before calling setup(). It installs the piper-tts package from PyPI into a venv inside the skill directory.

Usage

  • Input: text, optional format ("ogg" or "wav"), optional voice (model stem), optional lengthScale (speech speed, default 1.0)
  • Output: path to generated file (usually .ogg)

Controlling voice and language

To list installed voices, call listVoices() — returns stems of all installed .onnx models. Never assume a fixed list; it varies per user and installation.

Auto-detection (no voice param): The script detects language from the text using character and script analysis:

  • Non-Latin scripts: Cyrillic (Russian, Ukrainian, Bulgarian), Greek, Arabic, Persian, Chinese, Japanese, Korean, Georgian
  • Latin-script languages: Vietnamese, Polish, Romanian, Turkish, Czech, Slovak, Hungarian, Portuguese, Spanish, Catalan, German, Finnish, Scandinavian (Swedish, Norwegian, Danish), French, Italian
  • Fallback: English keywords → first English model → any installed model

Auto-detection is best-effort. For reliable results with a specific language, always pass the voice parameter explicitly.

Explicit override: set PIPER_VOICE_MODEL env var to a full .onnx path (overrides everything).

When the user requests a specific voice or language:

  1. Call listVoices() to see what is installed
  2. Pass the matching stem as voice to tts(), e.g. voice: "en_US-amy-medium"
  3. If the requested voice is not installed, offer to download it with downloadVoices([stem])

To switch back to auto-detect, omit the voice parameter.

Downloading additional voices

The user may say things like "I don't like this voice, use a female one" or "Download a German voice". When this happens:

  1. Find the model at https://github.com/rhasspy/piper/blob/master/VOICES.md
  2. Confirm the stem (e.g. de_DE-thorsten-medium) and call downloadVoices([stem])
  3. Generate a sample and send it to the user
  4. Confirm with listVoices() — the new voice is immediately usable

Removing voices

The user may say "remove that voice" or "I don't need the German voice anymore". When this happens:

  1. Call listVoices() to confirm which voices are installed
  2. Confirm with the user which voice to remove
  3. Call removeVoice(stem) — e.g. removeVoice('de_DE-thorsten-medium')
  4. Returns { removed, filesDeleted } on success
  5. If the removed voice was the user's preferred voice, ask them to pick a new one

Never remove the last remaining voice without warning the user that TTS will stop working.

Changing speech speed

The user may say things like "speak faster", "too slow", or "speed it up". When this happens:

  1. Ask what speed they want in %, or suggest: 125% (faster), 115%, 100% (normal), 80% (slower)
  2. Convert their % to lengthScale: lengthScale = 1 / (speed% / 100)
  3. Generate a short sample: await tts({ text: '...', voice: 'current-voice', lengthScale: 0.8 })
  4. Send the sample and confirm
  5. Offer to persist: "Save this as default?" — if yes, call saveConfig({ lengthScale: 0.8 })
  6. Use the new lengthScale for all subsequent tts() calls in the session

Where files are written

  • OPENCLAW_WORKSPACE/tts/ if OPENCLAW_WORKSPACE env var is set
  • otherwise: ~/.openclaw/workspace/tts/

Dependencies

  • python3 (3.8+) — required for setup() to create the venv
  • ffmpeg — for WAV → OGG/Opus conversion
  • espeak-ng — system library used by Piper internally; setup() checks for it and warns if missing. Install: sudo apt install espeak-ng (Debian/Ubuntu), sudo dnf install espeak-ng (Fedora), brew install espeak (macOS)
  • At least one Piper .onnx + .onnx.json voice model pair in the skill directory

Platform support

  • Linux x86_64: fully supported
  • macOS x86_64 / arm64: fully supported
  • Linux ARM: may require building piper-tts from source
  • Windows: not supported

Remove

rm -rf ~/.openclaw/skills/local-piper-tts-multilang-secure

This removes everything: skill code, venv, and all voice models.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,004
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,002
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,001
PHP集成RabbitMQ实现消息队列的完整步骤

使用 php-amqplib 库,通过建立连接、声明交换机与队列并绑定,即可在 PHP 中实现消息的发送与消费。

2026.05.24 1,001
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
Skill 文件
  • SKILL.md
    • local-piper-tts-multilang-secure
    • Description
    • Features
    • First-run flow — full agent procedure
      • Step 1 — check status
      • Step 2 — install Piper if needed
      • Step 3 — offer voice download if no models present
      • Step 4 — play samples so the user can choose
      • Step 5 — choose speech speed
      • Step 6 — note the preferred voice and speed
    • Before first use — always call status()
    • Usage
    • Controlling voice and language
    • Downloading additional voices
    • Removing voices
    • Changing speech speed
    • Where files are written
    • Dependencies
    • Platform support
    • Remove
  • 项目或源文件

相关 Skill

更多
claw-voice-local claw-voice-local 使用piper TTS将文本转为离线Telegram语音消息,用于智能体说话、发送音频或语音笔记。
Whisper Piper Voice Whisper Piper Voice 在本地搭建并运行一个语音管道,将 Whisper STT(语音转文本)与 Piper TTS(文本转语音)合并为一个 HTTP 服务器,用于响应本地语音服务的搭建需求。
Jarvis Vocal Jarvis Vocal 使用 Piper TTS 与HuggingFace 训练的模型实现真实的 J.A.R.V.I.S. 语音合成,能够在本地生成电影级精准语音,并推送到已连接的 Android 设备。
WhatsApp语音消息免费版 WhatsApp语音消息免费版 基于 Piper TTS 的 WhatsApp 语音消息发送工具,支持 40+ 语言,适合个人用户发送语音消息。
Piper TTS Piper TTS 使用Piper进行本地文字转语音,用于语音消息传递。当用户要求语音回复、音频消息、TTS、文字转语音、语音笔记等情况时使用。