@junwan666/remotion-elevenlabs 4.0.448-zh.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @remotion/elevenlabs
2
+
3
+ Work with the output of the ElevenLabs API
4
+
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/@remotion/elevenlabs.svg?style=flat&color=black&label=Downloads)](https://npmcharts.com/compare/@remotion/elevenlabs?minimal=true)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @remotion/elevenlabs --save-exact
11
+ ```
12
+
13
+ When installing a Remotion package, make sure to align the version of all `remotion` and `@remotion/*` packages to the same version.
14
+ Remove the `^` character from the version number to use the exact version.
15
+
16
+ ## Usage
17
+
18
+ See the [documentation](https://www.remotion.dev/docs/elevenlabs) for more information.
@@ -0,0 +1,9 @@
1
+ import type { Caption } from '@remotion/captions';
2
+ import type { ElevenLabsTranscript } from './elevenlabs-transcript';
3
+ export type ElevenLabsTranscriptToCaptionsInput = {
4
+ transcript: ElevenLabsTranscript;
5
+ };
6
+ export type ElevenLabsTranscriptToCaptionsOutput = {
7
+ captions: Caption[];
8
+ };
9
+ export declare const elevenLabsTranscriptToCaptions: ({ transcript, }: ElevenLabsTranscriptToCaptionsInput) => ElevenLabsTranscriptToCaptionsOutput;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.elevenLabsTranscriptToCaptions = void 0;
4
+ const elevenLabsTranscriptToCaptions = ({ transcript, }) => {
5
+ const captions = [];
6
+ if (!transcript || !transcript.words || !Array.isArray(transcript.words)) {
7
+ throw new Error('Invalid ElevenLabs transcript. The transcript must be generated with `timestamps_granularity` set to `"word"`. See https://www.remotion.dev/docs/elevenlabs/elevenlabs-transcript-to-captions');
8
+ }
9
+ const { words } = transcript;
10
+ let isFirst = true;
11
+ for (let i = 0; i < words.length; i++) {
12
+ const entry = words[i];
13
+ if (entry.type !== 'word') {
14
+ continue;
15
+ }
16
+ const prevEntry = i > 0 ? words[i - 1] : null;
17
+ const hasSpacing = prevEntry !== null && prevEntry.type === 'spacing';
18
+ const startMs = !isFirst && hasSpacing ? prevEntry.start * 1000 : entry.start * 1000;
19
+ const endMs = entry.end * 1000;
20
+ const text = isFirst ? entry.text : ` ${entry.text}`;
21
+ captions.push({
22
+ confidence: null,
23
+ startMs,
24
+ endMs,
25
+ text,
26
+ timestampMs: (startMs + endMs) / 2,
27
+ });
28
+ isFirst = false;
29
+ }
30
+ return { captions };
31
+ };
32
+ exports.elevenLabsTranscriptToCaptions = elevenLabsTranscriptToCaptions;
@@ -0,0 +1,14 @@
1
+ export type ElevenLabsTranscriptWord = {
2
+ text: string;
3
+ start: number;
4
+ end: number;
5
+ type: 'word' | 'spacing' | 'audio_event';
6
+ logprob: number;
7
+ };
8
+ export type ElevenLabsTranscript = {
9
+ language_code: string;
10
+ language_probability: number;
11
+ text: string;
12
+ words: ElevenLabsTranscriptWord[];
13
+ transcription_id: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { ElevenLabsTranscriptToCaptionsInput, ElevenLabsTranscriptToCaptionsOutput, elevenLabsTranscriptToCaptions, } from './elevenlabs-transcript-to-captions';
2
+ export { ElevenLabsTranscript, ElevenLabsTranscriptWord, } from './elevenlabs-transcript';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.elevenLabsTranscriptToCaptions = void 0;
4
+ const elevenlabs_transcript_to_captions_1 = require("./elevenlabs-transcript-to-captions");
5
+ Object.defineProperty(exports, "elevenLabsTranscriptToCaptions", { enumerable: true, get: function () { return elevenlabs_transcript_to_captions_1.elevenLabsTranscriptToCaptions; } });
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "repository": {
3
+ "url": "https://github.com/JunWan666/remotion-zh/tree/main/packages/elevenlabs"
4
+ },
5
+ "name": "@junwan666/remotion-elevenlabs",
6
+ "version": "4.0.448-zh.0",
7
+ "description": "Work with the output of the ElevenLabs API",
8
+ "main": "dist/index.js",
9
+ "sideEffects": false,
10
+ "bugs": {
11
+ "url": "https://github.com/remotion-dev/remotion/issues"
12
+ },
13
+ "scripts": {
14
+ "formatting": "oxfmt src --check",
15
+ "format": "oxfmt src",
16
+ "lint": "eslint src",
17
+ "test": "bun test src",
18
+ "make": "tsgo -d"
19
+ },
20
+ "author": "Jonny Burger <jonny@remotion.dev>",
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "@remotion/captions": "npm:@junwan666/remotion-captions@4.0.448-zh.0"
24
+ },
25
+ "peerDependencies": {},
26
+ "devDependencies": {
27
+ "@remotion/eslint-config-internal": "npm:@junwan666/remotion-eslint-config-internal@4.0.448-zh.0",
28
+ "eslint": "9.19.0",
29
+ "@typescript/native-preview": "7.0.0-dev.20260217.1"
30
+ },
31
+ "keywords": [
32
+ "remotion",
33
+ "elevenlabs"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "homepage": "https://www.remotion.dev/docs/elevenlabs"
39
+ }