@remotion/install-whisper-cpp
Version:
Helpers for installing and using Whisper.cpp
82 lines (81 loc) • 2.35 kB
TypeScript
import type { WhisperModel } from './download-whisper-model';
import type { Language } from './languages';
type Timestamps = {
from: string;
to: string;
};
type Offsets = {
from: number;
to: number;
};
type WordLevelToken = {
t_dtw: number;
text: string;
timestamps: Timestamps;
offsets: Offsets;
id: number;
p: number;
};
type TranscriptionItem = {
timestamps: Timestamps;
offsets: Offsets;
text: string;
};
type TranscriptionItemWithTimestamp = TranscriptionItem & {
tokens: WordLevelToken[];
};
type Model = {
type: string;
multilingual: boolean;
vocab: number;
audio: {
ctx: number;
state: number;
head: number;
layer: number;
};
text: {
ctx: number;
state: number;
head: number;
layer: number;
};
mels: number;
ftype: number;
};
type Params = {
model: string;
language: string;
translate: boolean;
};
type Result = {
language: string;
};
type AdditionalArgs = string[] | [string, string][];
export type TranscriptionJson<WithTokenLevelTimestamp extends boolean> = {
systeminfo: string;
model: Model;
params: Params;
result: Result;
transcription: true extends WithTokenLevelTimestamp ? TranscriptionItemWithTimestamp[] : TranscriptionItem[];
};
export type TranscribeOnProgress = (progress: number) => void;
export declare const modelToDtw: (model: WhisperModel) => string;
export declare const transcribe: <HasTokenLevelTimestamps extends boolean>({ inputPath, whisperPath, whisperCppVersion, model, modelFolder, translateToEnglish, tokenLevelTimestamps, printOutput, tokensPerItem, language, splitOnWord, signal, onProgress, flashAttention, additionalArgs, }: {
inputPath: string;
whisperPath: string;
whisperCppVersion: string;
model: WhisperModel;
tokenLevelTimestamps: HasTokenLevelTimestamps;
modelFolder?: string;
translateToEnglish?: boolean;
printOutput?: boolean;
tokensPerItem?: true extends HasTokenLevelTimestamps ? never : number | null;
language?: Language | null;
splitOnWord?: boolean;
signal?: AbortSignal;
onProgress?: TranscribeOnProgress;
flashAttention?: boolean;
additionalArgs?: AdditionalArgs;
}) => Promise<TranscriptionJson<HasTokenLevelTimestamps>>;
export {};