@remotion/install-whisper-cpp 4.0.140 → 4.0.142
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/dist/download-whisper-model.js +12 -14
- package/dist/index.d.ts +1 -0
- package/dist/languages.d.ts +5 -0
- package/dist/languages.js +6 -0
- package/dist/transcribe.d.ts +4 -1
- package/dist/transcribe.js +6 -4
- package/package.json +1 -1
|
@@ -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';
|
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, }: {
|
|
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;
|
|
@@ -65,5 +66,7 @@ export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inp
|
|
|
65
66
|
modelFolder?: string | undefined;
|
|
66
67
|
translateToEnglish?: boolean | undefined;
|
|
67
68
|
printOutput?: boolean | undefined;
|
|
69
|
+
tokensPerItem?: (true extends HasTokenLevelTimestamps ? never : number | null) | undefined;
|
|
70
|
+
language?: Language | null | undefined;
|
|
68
71
|
}) => Promise<TranscriptionJson<HasTokenLevelTimestamps>>;
|
|
69
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, }) => {
|
|
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`);
|
|
@@ -55,12 +55,12 @@ const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJ
|
|
|
55
55
|
'--output-file',
|
|
56
56
|
tmpJSONPath,
|
|
57
57
|
'--output-json',
|
|
58
|
-
'--max-len',
|
|
59
|
-
'1',
|
|
58
|
+
tokensPerItem ? ['--max-len', tokensPerItem] : null,
|
|
60
59
|
'-ojf', // Output full JSON
|
|
61
60
|
tokenLevelTimestamps ? ['--dtw', model] : null,
|
|
62
61
|
model ? [`-m`, `${modelPath}`] : null,
|
|
63
62
|
translate ? '-tr' : null,
|
|
63
|
+
language ? ['-l', language.toLowerCase()] : null,
|
|
64
64
|
]
|
|
65
65
|
.flat(1)
|
|
66
66
|
.filter(Boolean);
|
|
@@ -108,7 +108,7 @@ const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJ
|
|
|
108
108
|
});
|
|
109
109
|
return { outputPath };
|
|
110
110
|
};
|
|
111
|
-
const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, }) => {
|
|
111
|
+
const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, tokensPerItem, language, }) => {
|
|
112
112
|
if (!(0, node_fs_1.existsSync)(whisperPath)) {
|
|
113
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.`);
|
|
114
114
|
}
|
|
@@ -128,6 +128,8 @@ const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translat
|
|
|
128
128
|
translate: translateToEnglish,
|
|
129
129
|
tokenLevelTimestamps,
|
|
130
130
|
printOutput,
|
|
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);
|