私有 SDK · v1.0.0

为每个视频添加本地配音按钮

Voxylio SDK 可为您自己的 HTML5 视频播放器添加同步配音。字幕、媒体和语音在浏览器中处理,不会发送给 Voxylio,因此费用不会随观看时长增加。

  • 设备端语音
  • 不按分钟收费
  • 媒体不上传给 Voxylio
lesson-player.ts
import { Voxylio } from "@ln-dev7/voxylio-sdk";

const dubbing = await Voxylio.create({
  player: videoElement,
  captions: {
    sourceLanguage: "en",
    tracks: [
      { language: "en", src: "/captions/lesson.en.vtt" },
      { language: "fr", src: "/captions/lesson.fr.vtt" },
    ],
  },
  translation: { strategy: "provided-only" },
  speech: { localOnly: true, ducking: 0.18 },
  ui: { mount: false },
  license: { key: "vx_pk_your_public_site_key" },
});

startButton.addEventListener("click", async () => {
  await dubbing.prepare({ targetLanguage: "fr" });
  await dubbing.start();
});

媒体不发送给 Voxylio

字幕不发送给 Voxylio

语音不发送给 Voxylio

为平台而设计的配音层

无需自建播放引擎,也无需在每次观看课程时向 AI 服务商付费,即可为学习者提供其他语言。

架构上保障隐私

视频、字幕和生成的语音都在浏览器中处理。Voxylio 不会接收您的课程媒体或学习者内容。

成本可预测

一个固定订阅即可覆盖获许可的网站。没有分钟数、积分或意外的用量费用。

原生本地语音

SDK 使用学习者设备上安装的语音,包括可用时质量更高的系统语音。

您的播放器,您的界面

可使用现成组件,也可不挂载界面,将 Voxylio 接入您的控件、设计系统和分析工具。

工作原理

从字幕轨道到同步语音

SDK 与现有播放器协同工作。视频、字幕和产品体验始终由您掌控。

  1. 01

    提供字幕轨道

    传入源字幕和已翻译的 WebVTT 或 SRT 轨道。支持的语言对还可选择使用设备端翻译。

  2. 02

    连接播放器

    使用页面的 HTMLVideoElement、公开站点密钥和支持的语言初始化 Voxylio。

  3. 03

    让学习者收听

    学习者选择语言并开始配音。本地语音会跟随播放、暂停、跳转和播放速度。

专为可控集成而设计

Voxylio SDK 专注于可靠的本地路径:明确的字幕轨道、您可控制的播放器,以及由浏览器生成的语音。

WebVTT、SRT 和 cue 数据

可加载字幕文件或直接提供 cue。翻译来源和显示的语言均由您决定。

预先提供或设备端翻译

要获得稳定覆盖,请提供已翻译的轨道。在支持的环境中,也可启用浏览器的本地翻译引擎。

无头 API 或现成界面

使用紧凑组件快速上线,或通过 API 和事件打造完全定制的播放器体验。

简单的许可方式

一个固定价格,不计算分钟数。

您支付的是在平台中使用 SDK 的权利,而不是客户观看的每一节课程。

商业许可证

Voxylio SDK

适用于可控制自有视频播放器的课程平台、学院和 Web 应用。

$990/ 年

相当于每月 $82.50 · 每年节省 $198

申请 SDK 访问权限

私有 SDK 早期发布期间,访问权限将依据商业许可协议进行人工审批。

许可证包含

  • 1 个生产域名,以及 staging 和 localhost
  • 不限量本地配音——无分钟数或积分
  • 本地系统语音和同步播放
  • 无头 API、可选组件和 TypeScript 类型
  • 所有 v1 更新和集成文档
  • 电子邮件集成支持

需要多个生产域名?

请联系我们获取多域名或企业许可证,价格将根据您的部署规模确定。

SDK 不提供免费方案。浏览器扩展仍是独立的消费者产品;此许可证用于将 Voxylio 嵌入您自己的平台。

AI 就绪集成

把完整任务说明交给您的编程 AI

将此提示词复制到 Codex、Claude 或其他编程代理。它会要求代理先理解您的项目,再安全地安装和集成 SDK。

提示词涵盖项目分析、私有包安装、播放器与字幕检查、生命周期、隐私、测试和交付。

提示词使用英语,以便编程代理能够一致地执行。

voxylio-sdk-ai-integration-guide.md
You are integrating @ln-dev7/voxylio-sdk v1.0.0 into my existing website or web application.

Voxylio SDK adds synchronized, local-only dubbing to an existing HTML5 video player. It consumes timed captions, optionally translates them on-device when the browser supports it, and speaks them with a local system voice. Do not redesign the application or replace its current video architecture unless that is genuinely necessary.

IMPORTANT: follow the phases below in order.

PHASE 1 — UNDERSTAND THE PROJECT BEFORE CHANGING ANYTHING

Do not install packages, edit files, or generate implementation code yet.

First, inspect the existing project thoroughly and determine:

1. The framework, rendering model, language, package manager, lockfile, build tool, and deployment target.
2. Whether the application uses SSR, React Server Components, client components, SPA navigation, or another lifecycle model.
3. Where video players are created and destroyed.
4. Whether the player exposes a directly accessible HTMLVideoElement.
5. Whether the project uses a native HTML5 player, Video.js, Mux, another wrapper, or a cross-origin YouTube/Vimeo iframe.
6. Where video metadata and language options come from.
7. How captions are stored, authorized, and delivered: WebVTT/SRT URLs, existing TextTrack objects, an API returning normalized cues, same-origin files, or signed cross-origin URLs.
8. Which source and target languages are required, using valid BCP 47 codes such as en, fr, es, or pt-BR.
9. Whether approved translated caption tracks already exist for every target language.
10. The current UI, design system, accessibility conventions, loading states, and error-handling patterns.
11. The current Content Security Policy, CORS configuration, authentication model, and environment-variable conventions.
12. How cleanup happens when a player, lesson, modal, route, or component is removed.
13. Whether another feature on the same page already uses window.speechSynthesis.
14. The existing test setup and browsers officially supported by this project.

Search the actual repository and cite the relevant files in your audit. Do not guess.

Your first response must contain only:

- a concise architecture summary;
- the exact player and caption integration points you found;
- compatibility risks or blockers;
- the files you expect to change;
- your recommended integration plan;
- only the questions that cannot be answered by inspecting the repository.

If the player is only available inside a cross-origin YouTube or Vimeo iframe, explicitly state that the generic Voxylio v1 integration cannot access it. Do not pretend that a CSS selector can reach into that iframe. Recommend a provider-specific adapter or running Voxylio in a same-origin frame instead.

Wait for my confirmation before moving to Phase 2.

PHASE 2 — IMPLEMENT THE INTEGRATION AFTER CONFIRMATION

Before coding, read the installed package README and documentation and treat the installed version as the source of truth. Do not invent undocumented APIs.

1. INSTALL THE PRIVATE PACKAGE SAFELY

Voxylio is distributed as a private GitHub Packages module: @ln-dev7/voxylio-sdk

Configure the project-level .npmrc without placing a literal token in it:

@ln-dev7:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}

Then use the package manager already present in the project, for example:

pnpm add @ln-dev7/voxylio-sdk

or the equivalent npm, Yarn, or Bun command.

Security requirements:

- GITHUB_PACKAGES_TOKEN is a private installation credential.
- Give it only the package-read access required by the customer's GitHub configuration.
- Keep it in the developer environment and CI/deployment secret store.
- Never commit it, place it in browser code, or expose it through NEXT_PUBLIC_, VITE_, PUBLIC_, or another client-visible environment variable.
- The token is needed while installing/building the dependency, not while learners use the compiled application.
- The Voxylio site key starts with vx_pk_. It is intentionally public, belongs in browser configuration, and is restricted to licensed domains. It is not the GitHub registry token.

2. PRESERVE THE LOCAL-ONLY PRODUCT BOUNDARY

The built-in Voxylio v1 path must remain local-only:

- do not upload video or audio to Voxylio;
- do not send caption text or translations to Voxylio;
- do not add cloud transcription, translation, or text-to-speech;
- do not add per-minute tracking, playback history, or learner-identity telemetry;
- keep speech.localOnly set to true;
- do not connect a custom network TranslationProvider unless I explicitly approve that product and privacy change.

The production license payload sent to https://voxylio.lndev.me/api/sdk/license/verify contains only the public license key, current page origin/domain, and SDK version. As with any web request, the service infrastructure receives the request's network address. Voxylio derives a daily rotating HMAC bucket from it for abuse prevention, does not store the raw IP address in the license database, and deletes those rate-limit buckets within at most two days. The browser or operating system may separately download a system voice or on-device translation model.

3. CHOOSE THE CORRECT CAPTION STRATEGY

Voxylio v1 does not transcribe videos. Timed captions are required.

Use translation: { strategy: "provided-only" } as the production baseline when translated tracks exist. It works across current desktop Chrome, Edge, Firefox, and Safari when a matching local voice is installed.

Use translation: { strategy: "provided-then-device" } only as progressive enhancement. It uses a supplied target track first, then tries the browser's local Translator API. Firefox and Safari are supplied-track-only browsers in v1.

Use device-only only in a controlled Chrome or Edge desktop environment. Never advertise on-device translation as universally supported.

Caption tracks can be provided as URLs:

{ language: "fr", src: "/captions/lesson-01.fr.vtt" }

or as normalized in-memory cues:

{
  language: "fr",
  cues: [
    { start: 0.8, end: 3.1, text: "Bienvenue." },
    { start: 3.4, end: 6.2, text: "Commençons." }
  ]
}

Cue times are seconds on the video timeline. Use exactly one of src or cues whenever possible. Use BCP 47 tags consistently. If captions are protected, prefer same-origin authenticated URLs, short-lived signed URLs, or short-lived request headers. Never expose a durable server secret in browser JavaScript.

4. INTEGRATE ONLY ON THE CLIENT

Voxylio uses HTMLMediaElement, SpeechSynthesis, and browser events. Do not instantiate it during server rendering.

For Next.js, place the adapter behind a "use client" boundary and initialize it after the HTMLVideoElement ref exists. For another framework, use its browser-only mount lifecycle.

Pass a direct HTMLVideoElement reference. Do not pass a CSS selector, React component, player wrapper, or iframe. For Video.js, Mux, or another compatible wrapper, obtain the actual underlying video element through that player's documented API.

Use one controller per video element and allow only one active dubbing controller per page because Web Speech is shared by the browser document.

5. CREATE THE CONTROLLER USING THE REAL V1 API

Use this as a reference and adapt it to the project instead of copying it blindly:

import {
  Voxylio,
  type VoxylioController,
  type VoxylioErrorEventDetail,
  type VoxylioStatusEventDetail,
} from "@ln-dev7/voxylio-sdk";

let controller: VoxylioController | null = null;

controller = await Voxylio.create({
  player: videoElement,
  captions: {
    sourceLanguage: "en",
    tracks: [
      { language: "en", src: "/captions/lesson-01.en.vtt" },
      { language: "fr", src: "/captions/lesson-01.fr.vtt" },
    ],
  },
  translation: { strategy: "provided-only" },
  speech: {
    localOnly: true,
    rate: 1,
    pitch: 1,
    volume: 1,
    ducking: 0.18,
  },
  ui: { mount: false },
  license: { key: publicVoxylioSiteKey },
});

controller.addEventListener("statuschange", (event) => {
  const { state } = (event as CustomEvent<VoxylioStatusEventDetail>).detail;
  // Map idle, preparing, ready, running, paused, stopped, destroyed,
  // and error into the host application's UI.
});

controller.addEventListener("error", (event) => {
  const { code, error } = (event as CustomEvent<VoxylioErrorEventDetail>).detail;
  // Show a clear, accessible, actionable error without exposing a stack trace.
  console.error(code, error);
});

Voxylio.create(options) and createVoxylio(options) are equivalent and both return Promise<VoxylioController>.

Use ui.mount: false for a localized or branded interface. The packaged v1 widget is minimally styled and English-only. Do not mount it alongside custom controls.

6. REQUIRE AN EXPLICIT USER ACTION

Do not start dubbing on page load. Call prepare() and start() from a click, keyboard activation, or equivalent learner action:

async function startDubbing(targetLanguage: string) {
  if (!controller) return;
  try {
    await controller.prepare({ targetLanguage });
    await controller.start();
  } catch (error) {
    // Reuse the application's accessible error UI.
  }
}

function stopDubbing() {
  controller?.stop();
}

The host application still owns normal video playback. Do not retry prepare() in a tight loop. Handle PREPARE_ABORTED when a language change, stop(), destroy(), or a newer prepare() interrupts an in-flight preparation.

7. IMPLEMENT COMPLETE LIFECYCLE CLEANUP

Call controller.destroy() when the player is permanently removed, and remove every application-owned event listener.

In an SPA, destroy the controller during component or route cleanup. If Voxylio.create() is still pending when the component unmounts, mark the integration as disposed and immediately destroy the controller if that promise later resolves.

A destroyed controller cannot be reused. Recreate it when the underlying video element or caption configuration changes. Never leave a controller attached to a stale lesson or player.

8. BUILD AN ACCESSIBLE HOST UI

Include a target-language selector, explicit start and stop actions, a visible preparing state, an aria-live status region, disabled states during conflicting operations, and actionable messages for missing captions, unavailable translation, missing local voice, CORS failure, or invalid license. Keep original text captions available as an accessibility option.

Use controller.getState() for an initial snapshot and statuschange events for updates; do not poll. Use controller.getVoices() after preparation and controller.setVoice(exactVoiceName), or setVoice(null) for automatic selection. React to utterancestart when recording speech that actually began.

Handle these stable error codes: INVALID_OPTIONS, LICENSE_REQUIRED, LICENSE_INVALID, CAPTIONS_UNAVAILABLE, CAPTIONS_FETCH_FAILED, TRANSLATION_UNAVAILABLE, VOICE_UNAVAILABLE, PREPARE_ABORTED, NOT_PREPARED, DESTROYED, and INTERNAL_ERROR.

9. CONFIGURE CORS AND CSP NARROWLY

Same-origin caption requests use credentials: "same-origin" by default. For cross-origin captions, configure the exact course-site origin whenever possible:

Access-Control-Allow-Origin: https://courses.example.com
Content-Type: text/vtt; charset=utf-8

If cross-origin cookies are genuinely required, configure both sides explicitly with a concrete allowed origin and Access-Control-Allow-Credentials: true. Do not use a wildcard with credentials.

Preserve the existing Content Security Policy and add only the required connect-src origins:

Content-Security-Policy: default-src 'self'; connect-src 'self' https://voxylio.lndev.me https://captions.example.com

Do not use connect-src *. Register every real staging and production domain in the Voxylio license. Localhost, 127.0.0.1, [::1], and *.localhost skip license verification for development; public staging domains do not.

10. RESPECT THE V1 SUPPORT CONTRACT

Baseline: supplied translated tracks plus an installed local voice on desktop Chrome, Edge, Firefox, and Safari on macOS.

Progressive enhancement: on-device translation on compatible Chrome versions/language pairs, and Edge only where it exposes a compatible Translator API.

Outside v1: mobile browsers, videos without timed captions, voice cloning, cloud speech, automatic transcription, cross-origin YouTube/Vimeo iframe control, and identical voice quality across operating systems.

Do not use user-agent sniffing. Let prepare() test the actual captions, translation capability, and installed local voices.

11. VERIFY THE COMPLETE INTEGRATION

Run the existing formatter, linter, type checker, tests, and production build. Add tests for controller creation after the video exists, track configuration, user-initiated start, UI states, missing captions/voice, license rejection, interrupted language switching, cleanup, and the one-active-controller rule.

Also complete a real desktop-browser matrix with supplied tracks on Chrome, Edge, Firefox, and Safari; test Chrome/compatible Edge on-device fallback; then test play, pause, buffering, seeking both directions, playback-rate changes, stop/restart, language changes, CORS failures, invalid licenses, SPA navigation, volume restoration, and absence of repeated or stale speech after seeking.

Serve through HTTPS or localhost, never file://. Verify in the browser's network tools that no captions, audio, video, learner identity, or playback history are sent to Voxylio.

PHASE 3 — REPORT THE RESULT

After implementation, report:

1. Every file changed and why.
2. The selected translation strategy and why.
3. How the HTMLVideoElement and caption tracks are obtained.
4. How lifecycle cleanup and one-controller-per-document behavior are enforced.
5. CSP and CORS requirements.
6. Which checks and browsers were actually tested.
7. Remaining limitations or deployment steps.
8. Every assumption that still needs confirmation.

Do not claim production readiness if licensed domains, real caption delivery, installed voices, production CSP/CORS, or real-browser tests have not been verified.

SDK 常见问题

配音有上限或按分钟收费吗?+

没有。配音使用浏览器的本地能力,因此商业许可证没有分钟配额、积分或超额费用。

Voxylio 会接收哪些数据?+

许可证验证会发送公开许可证密钥、站点来源和 SDK 版本。与所有网络请求一样,基础设施会看到 IP 地址;Voxylio 仅为防滥用从中生成每日轮换的 HMAC 分桶,从不存储原始 IP,并会在两天内删除这些分桶。您的视频、字幕、生成的语音及学习者身份不会发送给 Voxylio。

支持哪些语言?+

只要您提供带时间轴的字幕轨道,且学习者拥有兼容的本地语音,就可以提供任何语言。可选的设备端翻译取决于浏览器支持。

能与我的视频播放器配合吗?+

如果您的应用能够提供底层 HTMLVideoElement,就可以。v1 不支持无法访问的第三方 iframe 中的播放器。

月付和年付如何计费?+

月付为 99 美元,每月续订。年付为 990 美元,一次支付十二个月。两者包含相同的 SDK 功能。

将本地配音加入您的平台

请介绍您的播放器、字幕流程和生产域名。我们将确认兼容性,并提供私有包访问权限和站点密钥。

申请访问