闲社服务运行正常AI智能体自动化平台
s

语音翻译器

技能标识:senseaudio-voice-translator

说中文出外语语音——按住说中文,2-3秒内播放英/日/韩语音。支持场景模式、双向对话、常用句收藏。

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

语音翻译器

技能名称: senseaudio-voice-translator
详细描述:

Voice Translator / 语音翻译器

按住说中文,松手后 2-3 秒内播放目标语言语音。出国旅行、跨国沟通即开即用。

工作流程

[按住录音] → ASR识别中文 → LLM场景化翻译 → TTS合成外语语音 → [播放]
双向模式:[录入外语] → ASR识别 → 翻译成中文 → TTS播放中文

核心 API

第一步:语音识别(ASR)

bash

录制音频后上传识别(中文)


curl https://api.senseaudio.cn/v1/audio/transcriptions \
-H Authorization: Bearer $SENSEAUDIOAPIKEY \
-F file=@recording.wav \
-F model=sense-asr \
-F language=zh \
-F response_format=text

返回:买单

双向模式识别外语(自动检测语言):
bash
curl https://api.senseaudio.cn/v1/audio/transcriptions \
-H Authorization: Bearer $SENSEAUDIOAPIKEY \
-F file=@foreign.wav \
-F model=sense-asr \
-F response_format=text

返回:Can I get the check please

第二步:场景化翻译(LLM)

翻译不是直译,而是目标语言的自然表达。通过系统提示注入场景上下文:

场景system prompt 关键词
餐厅restaurant, ordering food, dining
机场
airport, check-in, boarding, customs |
| 酒店 | hotel, check-in, room service, concierge |
| 出租车 | taxi, directions, destination |
| 购物 | shopping, price, discount, payment |
| 就医 | medical, symptoms, pharmacy, emergency |

翻译示例(餐厅场景):

  • - 中文买单 → Can I get the check, please? ✓(非 buy the bill ✗)
  • 中文这个怎么做的 → How is this dish prepared? ✓
  • 中文不要辣 → Could you make it not spicy, please? ✓

第三步:语音合成(TTS)

bash

英语播报


curl -X POST https://api.senseaudio.cn/v1/t2a_v2 \
-H Authorization: Bearer $SENSEAUDIOAPIKEY \
-H Content-Type: application/json \
-d {
model: SenseAudio-TTS-1.0,
text: Can I get the check, please?,
stream: false,
voice_setting: {
voiceid: female0001_a,
speed: 0.9
},
audio_setting: {
format: mp3,
sample_rate: 32000
}
} | python3 -c
import sys, json, subprocess
r = json.load(sys.stdin)
audio = bytes.fromhex(r[data][audio])
open(/tmp/translated.mp3,wb).write(audio)
subprocess.run([play,/tmp/translated.mp3])

完整 Python 实现

python
import os
import json
import requests
import subprocess
import tempfile

APIKEY = os.environ[SENSEAUDIOAPI_KEY]
ASR_URL = https://api.senseaudio.cn/v1/audio/transcriptions
TTSURL = https://api.senseaudio.cn/v1/t2av2

场景配置

SCENES = { restaurant: { name: 餐厅, prompt: You are translating for a customer in a restaurant. Use natural, polite expressions a native speaker would use when ordering food, asking about dishes, or requesting service., }, airport: { name: 机场, prompt: You are translating at an airport. Use standard travel expressions for check-in, boarding, customs, and baggage., }, hotel: { name: 酒店, prompt: You are translating at a hotel. Use polite hospitality expressions for check-in, room requests, and concierge services., }, taxi: { name: 出租车, prompt: You are translating in a taxi. Use clear, direct expressions for giving directions and destinations., }, shopping: { name: 购物, prompt: You are translating while shopping. Use natural expressions for asking prices, sizes, discounts, and payment., }, medical: { name: 就医, prompt: You are translating at a medical facility. Use clear, precise expressions for describing symptoms and seeking help., }, }

目标语言配置

LANGUAGES = { en: {name: 英语, voiceid: female0001_a}, ja: {name: 日语, voiceid: female0001_a}, ko: {name: 韩语, voiceid: female0001_a}, fr: {name: 法语, voiceid: female0001_a}, de: {name: 德语, voiceid: female0001_a}, es: {name: 西班牙语, voiceid: female0001_a}, }

LANG_NAMES = {
en: English, ja: Japanese, ko: Korean,
fr: French, de: German, es: Spanish,
}

def asr(audio_path: str, language: str = None) -> str:
语音识别
with open(audio_path, rb) as f:
data = {model: sense-asr, response_format: text}
if language:
data[language] = language
resp = requests.post(
ASR_URL,
headers={Authorization: fBearer {API_KEY}},
files={file: f},
data=data,
timeout=15,
)
resp.raiseforstatus()
return resp.text.strip()

def translate(text: str, target_lang: str, scene: str = None) -> str:
场景化翻译(调用 LLM)
scene_prompt = SCENES.get(scene, {}).get(prompt, Translate naturally.)
langname = LANGNAMES.get(targetlang, targetlang)

# 此处接入你的 LLM(如 Claude API)
# 示例 prompt:
system = f{sceneprompt} Translate the Chinese text to {langname}. Return ONLY the translated text, no explanations.
# user = text
# ... call LLM API ...
# 返回翻译结果
raise NotImplementedError(请接入 LLM 翻译接口)

def tts(text: str, target_lang: str) -> bytes:
文字转语音
voiceid = LANGUAGES.get(targetlang, {}).get(voiceid, female0001_a)
payload = {
model: SenseAudio-TTS-1.0,
text: text,
stream: False,
voicesetting: {voiceid: voice_id, speed: 0.9},
audiosetting: {format: mp3, samplerate: 32000},
}
resp = requests.post(
TTS_URL,
headers={Authorization: fBearer {API_KEY}, Content-Type: application/json},
json=payload,
timeout=15,
)
resp.raiseforstatus()
return bytes.fromhex(resp.json()[data][audio])

def playaudio(audiobytes: bytes):
播放音频
with tempfile.NamedTemporaryFile(suffix=.mp3, delete=False) as f:
f.write(audio_bytes)
tmp_path = f.name
# macOS: afplay, Linux: play (sox), Windows: start
for cmd in [[afplay, tmppath], [play, tmppath], [mpg123, tmp_path]]:
try:
subprocess.run(cmd, check=True, capture_output=True)
return
except (FileNotFoundError, subprocess.CalledProcessError):
continue

class VoiceTranslator:
def init(self, target_lang: str = en, scene: str = None, bidirectional: bool = False):
self.targetlang = targetlang
self.scene = scene
self.bidirectional = bidirectional
self.favorites: list[dict] = [] # 收藏的句子

def translatevoice(self, audiopath: str) -> dict:
主流程:录音 → 识别 → 翻译 → 合成 → 播放
# 1. ASR
src_lang = None if self.bidirectional else zh
recognized = asr(audiopath, language=srclang)

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 voice-translator-1776074769 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 voice-translator-1776074769 技能

通过命令行安装

skillhub install voice-translator-1776074769

下载

⬇ 下载 senseaudio-voice-translator v1.0.0(免费)

文件大小: 5.11 KB | 发布时间: 2026-4-15 14:52

v1.0.0 最新 2026-4-15 14:52
senseaudio-voice-translator 1.0.0

- Initial release of the voice translator skill.
- Speak Chinese and receive spoken output in English, Japanese, or Korean within 2–3 seconds.
- Features scenario-based translation, bi-directional conversation mode, and phrase favorites.
- Includes complete Python implementation and API usage documentation.
- Supports major travel and daily life scenarios (restaurant, airport, hotel, taxi, shopping, medical).
- Requires SENSEAUDIO_API_KEY and local tools (curl, python3).
返回顶部