@remotion/install-whisper-cpp 4.0.141 → 4.0.143
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.
|
@@ -80,25 +80,23 @@ const downloadWhisperModel = async ({ model, folder, printOutput = true, onProgr
|
|
|
80
80
|
// eslint-disable-next-line no-constant-condition
|
|
81
81
|
while (true) {
|
|
82
82
|
const { done, value } = await reader.read();
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (downloaded - lastPrinted > 1024 * 1024 * 10 ||
|
|
89
|
-
downloaded === totalFileSize) {
|
|
83
|
+
if (value) {
|
|
84
|
+
downloaded += value.length;
|
|
85
|
+
if (printOutput &&
|
|
86
|
+
(downloaded - lastPrinted > 1024 * 1024 * 10 ||
|
|
87
|
+
downloaded === totalFileSize)) {
|
|
90
88
|
console.log(`Downloaded ${downloaded} of ${contentLength} bytes (${((downloaded / Number(contentLength)) *
|
|
91
89
|
100).toFixed(2)}%)`);
|
|
92
90
|
lastPrinted = downloaded;
|
|
93
91
|
}
|
|
92
|
+
fileStream.write(value, () => {
|
|
93
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, totalFileSize);
|
|
94
|
+
if (downloaded === totalFileSize) {
|
|
95
|
+
fileStream.end();
|
|
96
|
+
resolve();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
94
99
|
}
|
|
95
|
-
fileStream.write(value, () => {
|
|
96
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress(downloaded, totalFileSize);
|
|
97
|
-
if (downloaded === totalFileSize) {
|
|
98
|
-
fileStream.end();
|
|
99
|
-
resolve();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
100
|
if (done) {
|
|
103
101
|
break;
|
|
104
102
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Caption, convertToCaptions } from './convert-to-captions';
|
|
2
2
|
export { OnProgress, WhisperModel, downloadWhisperModel, } from './download-whisper-model';
|
|
3
3
|
export { installWhisperCpp } from './install-whisper-cpp';
|
|
4
|
+
export type { Language } from './languages';
|
|
4
5
|
export { TranscriptionJson, transcribe } from './transcribe';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of supported languages of Whispher.
|
|
3
|
+
* https://github.com/ggerganov/whisper.cpp/blob/8f253ef3af1c62c04316ba4afa7145fc4d701a8c/whisper.cpp#L424
|
|
4
|
+
*/
|
|
5
|
+
export type Language = 'Afrikaans' | 'Albanian' | 'Amharic' | 'Arabic' | 'Armenian' | 'Assamese' | 'Azerbaijani' | 'Bashkir' | 'Basque' | 'Belarusian' | 'Bengali' | 'Bosnian' | 'Breton' | 'Bulgarian' | 'Burmese' | 'Castilian' | 'Catalan' | 'Chinese' | 'Croatian' | 'Czech' | 'Danish' | 'Dutch' | 'English' | 'Estonian' | 'Faroese' | 'Finnish' | 'Flemish' | 'French' | 'Galician' | 'Georgian' | 'German' | 'Greek' | 'Gujarati' | 'Haitian' | 'Haitian Creole' | 'Hausa' | 'Hawaiian' | 'Hebrew' | 'Hindi' | 'Hungarian' | 'Icelandic' | 'Indonesian' | 'Italian' | 'Japanese' | 'Javanese' | 'Kannada' | 'Kazakh' | 'Khmer' | 'Korean' | 'Lao' | 'Latin' | 'Latvian' | 'Letzeburgesch' | 'Lingala' | 'Lithuanian' | 'Luxembourgish' | 'Macedonian' | 'Malagasy' | 'Malay' | 'Malayalam' | 'Maltese' | 'Maori' | 'Marathi' | 'Moldavian' | 'Moldovan' | 'Mongolian' | 'Myanmar' | 'Nepali' | 'Norwegian' | 'Nynorsk' | 'Occitan' | 'Panjabi' | 'Pashto' | 'Persian' | 'Polish' | 'Portuguese' | 'Punjabi' | 'Pushto' | 'Romanian' | 'Russian' | 'Sanskrit' | 'Serbian' | 'Shona' | 'Sindhi' | 'Sinhala' | 'Sinhalese' | 'Slovak' | 'Slovenian' | 'Somali' | 'Spanish' | 'Sundanese' | 'Swahili' | 'Swedish' | 'Tagalog' | 'Tajik' | 'Tamil' | 'Tatar' | 'Telugu' | 'Thai' | 'Tibetan' | 'Turkish' | 'Turkmen' | 'Ukrainian' | 'Urdu' | 'Uzbek' | 'Valencian' | 'Vietnamese' | 'Welsh' | 'Yiddish' | 'Yoruba' | 'Zulu' | 'auto' | 'af' | 'am' | 'ar' | 'as' | 'az' | 'ba' | 'be' | 'bg' | 'bn' | 'bo' | 'br' | 'bs' | 'ca' | 'cs' | 'cy' | 'da' | 'de' | 'el' | 'en' | 'es' | 'et' | 'eu' | 'fa' | 'fi' | 'fo' | 'fr' | 'gl' | 'gu' | 'ha' | 'haw' | 'he' | 'hi' | 'hr' | 'ht' | 'hu' | 'hy' | 'id' | 'is' | 'it' | 'ja' | 'jw' | 'ka' | 'kk' | 'km' | 'kn' | 'ko' | 'la' | 'lb' | 'ln' | 'lo' | 'lt' | 'lv' | 'mg' | 'mi' | 'mk' | 'ml' | 'mn' | 'mr' | 'ms' | 'mt' | 'my' | 'ne' | 'nl' | 'nn' | 'no' | 'oc' | 'pa' | 'pl' | 'ps' | 'pt' | 'ro' | 'ru' | 'sa' | 'sd' | 'si' | 'sk' | 'sl' | 'sn' | 'so' | 'sq' | 'sr' | 'su' | 'sv' | 'sw' | 'ta' | 'te' | 'tg' | 'th' | 'tk' | 'tl' | 'tr' | 'tt' | 'uk' | 'ur' | 'uz' | 'vi' | 'yi' | 'yo' | 'zh';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
4
|
const convert_to_captions_1 = require("../convert-to-captions");
|
|
5
5
|
const example_payload_1 = require("./example-payload");
|
|
6
|
-
(0,
|
|
6
|
+
(0, bun_test_1.test)('Convert to captions - 200ms together', () => {
|
|
7
7
|
const { captions: transcript } = (0, convert_to_captions_1.convertToCaptions)({
|
|
8
8
|
transcription: example_payload_1.examplePayload.transcription,
|
|
9
9
|
combineTokensWithinMilliseconds: 200,
|
|
10
10
|
});
|
|
11
|
-
(0,
|
|
11
|
+
(0, bun_test_1.expect)(transcript).toEqual([
|
|
12
12
|
{ text: 'William', startInSeconds: 0.24 },
|
|
13
13
|
{ text: 'just', startInSeconds: 0.48 },
|
|
14
14
|
{ text: 'hit 100,000', startInSeconds: 0.7 },
|
|
@@ -120,12 +120,12 @@ const example_payload_1 = require("./example-payload");
|
|
|
120
120
|
{ text: 'beeping)', startInSeconds: 63.02 },
|
|
121
121
|
]);
|
|
122
122
|
});
|
|
123
|
-
(0,
|
|
123
|
+
(0, bun_test_1.test)('Convert to captions - 0ms together', () => {
|
|
124
124
|
const { captions: transcript } = (0, convert_to_captions_1.convertToCaptions)({
|
|
125
125
|
transcription: example_payload_1.examplePayload.transcription,
|
|
126
126
|
combineTokensWithinMilliseconds: 0,
|
|
127
127
|
});
|
|
128
|
-
(0,
|
|
128
|
+
(0, bun_test_1.expect)(transcript).toEqual([
|
|
129
129
|
{ text: 'William', startInSeconds: 0.24 },
|
|
130
130
|
{ text: 'just', startInSeconds: 0.48 },
|
|
131
131
|
{ text: 'hit', startInSeconds: 0.7 },
|
package/dist/transcribe.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WhisperModel } from './download-whisper-model';
|
|
2
|
+
import type { Language } from './languages';
|
|
2
3
|
type Timestamps = {
|
|
3
4
|
from: string;
|
|
4
5
|
to: string;
|
|
@@ -57,7 +58,7 @@ export type TranscriptionJson<WithTokenLevelTimestamp extends boolean> = {
|
|
|
57
58
|
result: Result;
|
|
58
59
|
transcription: true extends WithTokenLevelTimestamp ? TranscriptionItemWithTimestamp[] : TranscriptionItem[];
|
|
59
60
|
};
|
|
60
|
-
export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inputPath, whisperPath, model, modelFolder, translateToEnglish, tokenLevelTimestamps, printOutput, tokensPerItem, }: {
|
|
61
|
+
export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inputPath, whisperPath, model, modelFolder, translateToEnglish, tokenLevelTimestamps, printOutput, tokensPerItem, language, }: {
|
|
61
62
|
inputPath: string;
|
|
62
63
|
whisperPath: string;
|
|
63
64
|
model: WhisperModel;
|
|
@@ -66,5 +67,6 @@ export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inp
|
|
|
66
67
|
translateToEnglish?: boolean | undefined;
|
|
67
68
|
printOutput?: boolean | undefined;
|
|
68
69
|
tokensPerItem?: (true extends HasTokenLevelTimestamps ? never : number | null) | undefined;
|
|
70
|
+
language?: Language | null | undefined;
|
|
69
71
|
}) => Promise<TranscriptionJson<HasTokenLevelTimestamps>>;
|
|
70
72
|
export {};
|
package/dist/transcribe.js
CHANGED
|
@@ -43,7 +43,7 @@ const readJson = async (jsonPath) => {
|
|
|
43
43
|
const data = await node_fs_1.default.promises.readFile(jsonPath, 'utf8');
|
|
44
44
|
return JSON.parse(data);
|
|
45
45
|
};
|
|
46
|
-
const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJSONPath, modelFolder, translate, tokenLevelTimestamps, printOutput, tokensPerItem, }) => {
|
|
46
|
+
const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJSONPath, modelFolder, translate, tokenLevelTimestamps, printOutput, tokensPerItem, language, }) => {
|
|
47
47
|
const modelPath = (0, download_whisper_model_1.getModelPath)(modelFolder !== null && modelFolder !== void 0 ? modelFolder : whisperPath, model);
|
|
48
48
|
if (!node_fs_1.default.existsSync(modelPath)) {
|
|
49
49
|
throw new Error(`Error: Model ${model} does not exist at ${modelFolder ? modelFolder : modelPath}. Check out the downloadWhisperModel() API at https://www.remotion.dev/docs/install-whisper-cpp/download-whisper-model to see how to install whisper models`);
|
|
@@ -60,6 +60,7 @@ const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJ
|
|
|
60
60
|
tokenLevelTimestamps ? ['--dtw', model] : null,
|
|
61
61
|
model ? [`-m`, `${modelPath}`] : null,
|
|
62
62
|
translate ? '-tr' : null,
|
|
63
|
+
language ? ['-l', language.toLowerCase()] : null,
|
|
63
64
|
]
|
|
64
65
|
.flat(1)
|
|
65
66
|
.filter(Boolean);
|
|
@@ -107,7 +108,7 @@ const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJ
|
|
|
107
108
|
});
|
|
108
109
|
return { outputPath };
|
|
109
110
|
};
|
|
110
|
-
const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, tokensPerItem, }) => {
|
|
111
|
+
const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, tokensPerItem, language, }) => {
|
|
111
112
|
if (!(0, node_fs_1.existsSync)(whisperPath)) {
|
|
112
113
|
throw new Error(`Whisper does not exist at ${whisperPath}. Double-check the passed whisperPath. If you havent installed whisper, check out the installWhisperCpp() API at https://www.remotion.dev/docs/install-whisper-cpp/install-whisper-cpp to see how to install whisper programatically.`);
|
|
113
114
|
}
|
|
@@ -128,6 +129,7 @@ const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translat
|
|
|
128
129
|
tokenLevelTimestamps,
|
|
129
130
|
printOutput,
|
|
130
131
|
tokensPerItem: tokenLevelTimestamps ? 1 : tokensPerItem !== null && tokensPerItem !== void 0 ? tokensPerItem : 1,
|
|
132
|
+
language,
|
|
131
133
|
});
|
|
132
134
|
const json = (await readJson(tmpJSONPath));
|
|
133
135
|
node_fs_1.default.unlinkSync(tmpJSONPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/install-whisper-cpp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.143",
|
|
4
4
|
"description": "Install helper for Whisper.cpp",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"eslint-plugin-react": "7.32.2",
|
|
29
29
|
"eslint-plugin-react-hooks": "4.4.0",
|
|
30
30
|
"prettier": "3.2.5",
|
|
31
|
-
"prettier-plugin-organize-imports": "3.2.4"
|
|
32
|
-
"vitest": "0.31.1"
|
|
31
|
+
"prettier-plugin-organize-imports": "3.2.4"
|
|
33
32
|
},
|
|
34
33
|
"keywords": [
|
|
35
34
|
"remotion",
|
|
@@ -44,6 +43,6 @@
|
|
|
44
43
|
"lint": "eslint src --ext ts,tsx",
|
|
45
44
|
"build": "tsc -d",
|
|
46
45
|
"watch": "tsc -w",
|
|
47
|
-
"test": "
|
|
46
|
+
"test": "bun test src"
|
|
48
47
|
}
|
|
49
48
|
}
|