🎥 Make videos programmatically with React
add parameter maxLength to transcribe
Youssefb00b62432914
diff --git a/packages/docs/docs/install-whisper-cpp/transcribe.mdx b/packages/docs/docs/install-whisper-cpp/transcribe.mdxindex 4b86bf83d9..8cef8537a2 100644--- a/packages/docs/docs/install-whisper-cpp/transcribe.mdx+++ b/packages/docs/docs/install-whisper-cpp/transcribe.mdx@@ -95,6 +95,18 @@ We recommend using at least the `medium` model to get satisfactory results whenWhether to print the output of the transcription process to the console. Defaults to `true`.+### `maxLength?`<AvailableFrom v="4.0.141" />++_optional - default: `1`_++The maximum amount of tokens included in each transcription item.++Set this flag to `null`, to use `whisper.cpp`'s default token grouping (useful for generating a movie-style transcription).++:::info+`maxLength` can only be set when `tokenLevelTimestamps` is set to `false`.+:::+## Return value### `TranscriptionJson`diff --git a/packages/install-whisper-cpp/src/transcribe.ts b/packages/install-whisper-cpp/src/transcribe.tsindex a5b465e8cd..671b470328 100644--- a/packages/install-whisper-cpp/src/transcribe.ts+++ b/packages/install-whisper-cpp/src/transcribe.ts@@ -97,6 +97,7 @@ const transcribeToTempJSON = async ({translate,tokenLevelTimestamps,printOutput,+ maxLength,}: {fileToTranscribe: string;whisperPath: string;@@ -106,6 +107,7 @@ const transcribeToTempJSON = async ({translate: boolean;tokenLevelTimestamps: boolean;printOutput: boolean;+ maxLength: number | null;}): Promise<{outputPath: string;}> => {@@ -127,8 +129,7 @@ const transcribeToTempJSON = async ({'--output-file',tmpJSONPath,'--output-json',- '--max-len',- '1',+ maxLength ? ['--max-len', maxLength] : null,'-ojf', // Output full JSONtokenLevelTimestamps ? ['--dtw', model] : null,model ? [`-m`, `${modelPath}`] : null,@@ -207,6 +208,7 @@ export const transcribe = async <HasTokenLevelTimestamps extends boolean>({translateToEnglish = false,tokenLevelTimestamps,printOutput = true,+ maxLength,}: {inputPath: string;whisperPath: string;@@ -215,6 +217,7 @@ export const transcribe = async <HasTokenLevelTimestamps extends boolean>({modelFolder?: string;translateToEnglish?: boolean;printOutput?: boolean;+ maxLength?: true extends HasTokenLevelTimestamps ? never : number | null;}): Promise<TranscriptionJson<HasTokenLevelTimestamps>> => {if (!existsSync(whisperPath)) {throw new Error(@@ -243,6 +246,7 @@ export const transcribe = async <HasTokenLevelTimestamps extends boolean>({translate: translateToEnglish,tokenLevelTimestamps,printOutput,+ maxLength: tokenLevelTimestamps ? 1 : maxLength ?? 1,});const json = (await readJson(