SuperAPI AI 工具集

openclaw-videotranslate-skill

办公与效率

查看项目

更新于 10-16 02:42

技能介绍

OpenClaw 视频翻译与配音技能(openclaw-videotranslate-skill)出自 Hermes Skills 合集,作者为 ara.so。它是一个用于视频字幕翻译与多语言配音生成的专业级 OpenClaw 技能,内置 3D 自适应调度器,用于处理 API 速率限制、自动音频时长对齐,并输出无损多轨视频。

【用途】 以两种模式处理视频:

  1. 仅字幕模式:翻译字幕并保留原始音频,输出双语字幕视频。
  2. 字幕+配音模式:翻译字幕并生成目标语言的 TTS 音频,自动进行时间轴对齐。

【主要能力】

  • 提取内嵌或外部字幕(SRT/VTT)。
  • 使用 LLM 或网页翻译 API 进行翻译。
  • 通过语音映射生成自然的 TTS 音频。
  • 自动拉伸/压缩音频以匹配原始时间轴。
  • 输出无损多轨 MKV 视频。
  • 以 3D 自适应调度(批大小、负载大小、并发数)处理 API 速率限制。

【安装与环境】 前置条件:安装 FFmpeg。 macOS:brew install ffmpeg Ubuntu/Debian:sudo apt install ffmpeg Windows(Chocolatey):choco install ffmpeg

安装技能: git clone https://github.com/zbjincheng/openclaw-skill-videotranslate.git cd openclaw-skill-videotranslate pip install -e . 或安装开发依赖:pip install -e ".[dev]"

环境配置:复制 .env.example 为 .env,并添加 API 凭据。 TRANSLATION_ENDPOINT=https://api.openai.com/v1/chat/completions TRANSLATION_CREDENTIAL=your_api_key_here TTS_ENDPOINT=https://api.openai.com/v1/audio/speech TTS_CREDENTIAL=your_api_key_here

【配置】 技能通过 manifest.yaml 配置。可配置参数包括:video_path(必填,源视频路径)、subtitle_path(可选,外部字幕文件,省略时提取内嵌字幕)、source_language 与 target_language(必填,语言代码如 en、zh-CN、ja、es、fr、de、ko)、processing_mode(必填枚,subtitle_only 或 subtitle_and_dubbing)、translation_provider(必填枚,llm 或 web)、translation_endpoint 与 translation_credential(必填)、tts_provider、tts_endpoint、tts_credential(当 processing_mode 为 subtitle_and_dubbing 时必填),以及可选的调度器参数(max_concurrency、initial_batch_size、max_payload_tokens、backoff_multiplier)。

【使用方式】 支持 Python API 调用(TranslationDubbingSkill 类,配合 ProcessingMode 枚)与命令行接口。 基础字幕翻译示例: from translation_dubbing_skill.entry import TranslationDubbingSkill from translation_dubbing_skill.models import ProcessingMode skill = TranslationDubbingSkill( video_path="input.mp4", source_language="en", target_language="zh-CN", processing_mode=ProcessingMode.SUBTITLE_ONLY, translation_provider="llm", translation_endpoint="https://api.openai.com/v1/chat/completions", translation_credential="${TRANSLATION_CREDENTIAL}", output_dir="./output" ) result = skill.execute()

完整翻译+配音示例: skill = TranslationDubbingSkill( video_path="lecture.mp4", subtitle_path="lecture.srt", source_language="en", target_language="ja", processing_mode=ProcessingMode.SUBTITLE_AND_DUBBING, translation_provider="llm", translation_endpoint="https://api.openai.com/v1/chat/completions", translation_credential="${TRANSLATION_CREDENTIAL}", tts_provider="llm", tts_endpoint="https://api.openai.com/v1/audio/speech", tts_credential="${TTS_CREDENTIAL}", output_dir="./output" ) result = skill.execute()

命令行用法: openclaw-videotranslate --video input.mp4 --source en --target zh-CN

【输出结构】 视频:原始视频流(无损复制) 音轨 1(默认):目标语言配音 音轨 2:原始源语言 字幕轨 1(默认):目标语言翻译字幕 字幕轨 2:原始源语言字幕

【字幕与音频处理】 SubtitleParser 可解析 SRT/VTT,SubtitleEntry 用于构建字幕对象,SubtitleSerializer 写出翻译后字幕。LLM 翻译提供者会自动剥离 <think> 推理块、稳健解析 JSON 响应、在上下文超限时切片负载、支持自定义系统提示词。LLM TTS 提供者支持语音映射(如 narrator→alloy、speaker1→echo、speaker2→nova)。AudioAligner 使用时间拉伸(非变调)对齐音频时长,以保留音质。VideoMuxer 生成多轨输出。

【进度与错误处理】 可通过 ProgressListener 监听状态变化、错误与完成事件。内置错误类型包括 SubtitleExtractionError、TranslationAPIError、TTSAPIError、AudioAlignmentError、VideoMuxingError、RateLimitError。3D 调度器自动处理 HTTP 429(指数退避加抖动)、上下文窗口溢出(负载切片重新分批)与网络错误(可配置重试)。

【适用场景】 需要为视频生成多语言字幕与配音的场合,如教程、讲座等内容的本地化处理,尤其是需保留原音并输出多轨视频的场景。

【限制】 需自行提供翻译与 TTS 的 API 端点与凭据;需本地安装 FFmpeg。资料未提供具体价格、性能指标或效果保证。