Liber SpeechAPI
后端与安装(必读)
本 Skill 只是客户端。没有正在运行的 Liber Speech 语音服务时,health / tts / asr / vc 都无法工作。
| 来源 | 地址 |
|---|---|
| 后端仓库 | https://github.com/liberalchang/Liber_SpeechAPI |
| 本仓库镜像 | https://github.com/liberalchang/liber_openclaw 的 Liber_SpeechAPI/ 子模块(与上面同一套代码) |
在有 Docker 的机器上安装并启动后端(默认 http://127.0.0.1:5555):
git clone https://github.com/liberalchang/Liber_SpeechAPI.git
cd Liber_SpeechAPI
cp .env.example .env
docker compose build
docker compose up -d
已经克隆本仓库时,进入 Liber_SpeechAPI/ 后执行同样的 cp .env.example .env、docker compose build、docker compose up -d。服务端 LIBER_SPEECH_API_KEY 留空则免鉴权;设置了密钥时,客户端 LIBER_API_KEY 必须与它相同。权重不随仓库分发,首次合成由服务下载。环境变量、离线权重和接口细节见后端 README。
安装本 Skill 客户端:Python 3.10+,在本 Skill 目录执行 pip install -r requirements.txt(锁定 requests==2.34.2)。然后按下方 Configuration 设置 LIBER_API_BASE_URL。
与 OpenClaw 语音插件的分工(必读)
| 场景 | 走哪条通道 |
|---|---|
聊天框听写、上传语音自动转写、/tts / 明确朗读、频道自动语音条、Talk 连续对话 |
OpenClaw 语音提供商插件(liber-speech,Task 3)——日常主通道 |
服务诊断(health/models/help)、批量字幕(srt/vtt)、词级时间戳 / VAD / 热词调优、精细语速响度、VC 换音、非插件环境兜底脚本 |
本 Skill(liber-speechapi)——高级 / 运维 / 批量工具 |
已安装语音插件时,不要用本 Skill 劫持日常对话朗读或听写。
本 Skill 负责
- 服务端诊断与自发现:
health、models、help(11 个 TTS 包、3 个 ASR、2 个 VC) - 高级 / 批量命令行:批量转写、导出字幕、词级时间戳、VAD/热词/prompt、
speed/exaggeration/cfg_weight/normalize_loudness - 音色替换(VC:
chatterbox/seed-vc)——插件明确不做 VC - 独立于 OpenClaw 网关或非插件环境的兜底脚本(含旧 Telegram 脚本兼容)
Follow this workflow
- Read
references/config.mdto resolve.envandspeechapi_config.json. - Read
references/workflow.mdfor advanced / VC workflows(日常听写朗读见语音插件)。 - Read
references/api.mdfor v2/v1 endpoint details. - Read
references/parameters.mdfor TTS/ASR/VC parameter meanings and defaults. - Use
scripts/liber_speech_client.pyfor deterministic calls instead of rewriting HTTP logic. - Use
/api/v2/helpwhen you need the authoritative parameter list for a model.
API version
- New deployments support
/api/v2: file upload → JSON request. - Old deployments only support
/api/v1: multipart request. - The client defaults to
auto: probe/api/v2/help, then fall back to/api/v1. - Force a version with
--api-version v1|v2orLIBER_API_VERSION. - v2-only parameters on a v1 server fail with a clear error instead of being silently ignored.
Configuration
.env:
LIBER_API_BASE_URL:http://host:5555,.../api/v1, or.../api/v2LIBER_API_KEY: same value as the server'sLIBER_SPEECH_API_KEY(服务端留空时本客户端也可不传密钥)LIBER_API_VERSION: optionalauto/v1/v2
加载优先级:CLI > 进程环境变量 > ~/.openclaw/.env > 本 Skill 目录 .env。不读取当前工作目录的 .env。从 .env 文件只复制上面三个 LIBER_API_* 键,其它键留在文件里,不进入进程环境。
speechapi_config.json:
asr、tts、vc、globalsectionsoptionsobject inside each section for model-specific parameters- values
"default"ornullare omitted from requests language默认是default(不传)。不锁定中文或任何其它语言。用户用--language(如zh、en、ja)或在配置里写language自行选择;省略时由服务端自动检测或使用服务端默认。下文命令里的--language zh只是示例。- 旧版配置(无
vc/options、含insanely-fast-whisper废弃字段)可加载:值为default的废弃字段静默丢弃,非default会告警或温和规范化。告警不回显hf_token等密钥字段的原值。
Never print or log API keys or legacy hf_token values.
Health, models, and help
python scripts/liber_speech_client.py health
python scripts/liber_speech_client.py models
python scripts/liber_speech_client.py help
python scripts/liber_speech_client.py help tts multilingual_v3
python scripts/liber_speech_client.py help asr large-v3 --include model
python scripts/liber_speech_client.py help vc seed-vc --format markdown
models uses v2 /api/v2/models when available and falls back to /api/v1/models.
Direct text-to-speech
python scripts/liber_speech_client.py tts "你好世界" --language zh --format wav
python scripts/liber_speech_client.py tts "你好世界" --speed 0.9 --exaggeration 0.7 --cfg-weight 0.3
python scripts/liber_speech_client.py tts "你好世界" --params '{"temperature":0.8,"top_p":0.9}'
python scripts/liber_speech_client.py tts "你好世界" --format ogg_opus
- Default output:
wav;Telegram 兼容语音条用ogg_opus(本地保存后缀.ogg)。 - v2 supports
speed,exaggeration,cfg_weight,temperature,repetition_penalty,min_p,top_p,top_k,norm_loudness,normalize_loudness,target_lufs,ref_start,ref_duration. - Model differences:
- multilingual / standard / language packs:
exaggeration,cfg_weight,speed - turbo / nano:
speed,temperature,top_p,top_k; noexaggeration/cfg_weight - v1 servers: only
model,language,format, and reference audio
- multilingual / standard / language packs:
- Reference audio is uploaded as
prompt_file_idon v2 and as form fieldprompton v1(不是旧的audio_prompt)。
Direct speech-to-text
python scripts/liber_speech_client.py asr audio.wav --language zh
python scripts/liber_speech_client.py asr audio.wav --timestamps word
python scripts/liber_speech_client.py asr audio.wav --vad-filter --initial-prompt "术语"
python scripts/liber_speech_client.py asr audio.wav --output srt
- Default output: structured JSON;
text,srt,vttare available. - Backend:
faster-whisper(large-v3/large-v3-turbo)与qwen3-asr-1.7b(不再使用insanely-fast-whisper)。 - v2 supports
timestamps=none|segment|word, VAD,initial_prompt,hotwords,beam_size,condition_on_previous_text. - Qwen3-ASR supports
timestamps,max_new_tokens, andmax_inference_batch_size; it does not support VAD, beam, hotwords,initial_prompt, ortask=translate. - Batch transcription writes results next to each input;
--outputis only valid for a single input.
Voice conversion
python scripts/liber_speech_client.py vc source.wav --prompt ref.wav --model seed-vc --convert-all
python scripts/liber_speech_client.py vc source.wav --prompt ref.wav --segments '[{"start":0,"end":3.2}]'
python scripts/liber_speech_client.py vc source.wav --prompt ref.wav --seed 42 --diffusion-steps 20
- VC requires v2;语音插件不做 VC,换音请用本 Skill。
- Seed-VC supports
seed,diffusion_steps,inference_cfg_rate,n_quantizers,temperature,max_window,context,fade,ref_max_len,length_adjust,overlap_frame_len. - Chatterbox VC has no model-level sampling parameters; reference audio uses the first 10 seconds.
Safety and robustness
- Never print or log API keys. 旧配置里的
hf_token只报告字段名,告警写成<redacted>。 - 权限范围:只读
LIBER_API_BASE_URL、LIBER_API_KEY、LIBER_API_VERSION;网络只访问配置的语音服务 origin;音频写到results/或用户给出的输出路径,拒绝写到.env、.ssh、.aws等凭据位置。 - 下载绝对
audio_url时校验同源:跨源默认拒绝,避免把Authorization发到非同源主机。 - 上传得到的临时文件由服务端按
expires_at过期清理。客户端自动上传 TTS 参考音频、ASR 输入和 VC 源/参考音频,不要求代理去删除这些文件。 - Validate input files and non-empty text before calls.
- Use timeouts; default 120s, synthesis/transcription/VC 600s.
- Retry only connection errors, timeouts, and HTTP 5xx; do not retry 4xx.
- Exit codes:
0success,2config/input,3network/service unreachable,4API error. - If clone audio is configured but missing, continue without cloning.
- Use
/api/v2/helprather than hardcoding parameter ranges or model capabilities.
