@remotion/install-whisper-cpp 4.0.139 → 4.0.141

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.
@@ -57,7 +57,7 @@ export type TranscriptionJson<WithTokenLevelTimestamp extends boolean> = {
57
57
  result: Result;
58
58
  transcription: true extends WithTokenLevelTimestamp ? TranscriptionItemWithTimestamp[] : TranscriptionItem[];
59
59
  };
60
- export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inputPath, whisperPath, model, modelFolder, translateToEnglish, tokenLevelTimestamps, printOutput, }: {
60
+ export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inputPath, whisperPath, model, modelFolder, translateToEnglish, tokenLevelTimestamps, printOutput, tokensPerItem, }: {
61
61
  inputPath: string;
62
62
  whisperPath: string;
63
63
  model: WhisperModel;
@@ -65,5 +65,6 @@ export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inp
65
65
  modelFolder?: string | undefined;
66
66
  translateToEnglish?: boolean | undefined;
67
67
  printOutput?: boolean | undefined;
68
+ tokensPerItem?: (true extends HasTokenLevelTimestamps ? never : number | null) | undefined;
68
69
  }) => Promise<TranscriptionJson<HasTokenLevelTimestamps>>;
69
70
  export {};
@@ -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, }) => {
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,8 +55,7 @@ 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,
@@ -108,7 +107,7 @@ const transcribeToTempJSON = async ({ fileToTranscribe, whisperPath, model, tmpJ
108
107
  });
109
108
  return { outputPath };
110
109
  };
111
- const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, }) => {
110
+ const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translateToEnglish = false, tokenLevelTimestamps, printOutput = true, tokensPerItem, }) => {
112
111
  if (!(0, node_fs_1.existsSync)(whisperPath)) {
113
112
  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
113
  }
@@ -128,6 +127,7 @@ const transcribe = async ({ inputPath, whisperPath, model, modelFolder, translat
128
127
  translate: translateToEnglish,
129
128
  tokenLevelTimestamps,
130
129
  printOutput,
130
+ tokensPerItem: tokenLevelTimestamps ? 1 : tokensPerItem !== null && tokensPerItem !== void 0 ? tokensPerItem : 1,
131
131
  });
132
132
  const json = (await readJson(tmpJSONPath));
133
133
  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.139",
3
+ "version": "4.0.141",
4
4
  "description": "Install helper for Whisper.cpp",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,