UNPKG

subtitles-generator

Version:

Generate subtitles easily with ffmpeg and whisper

51 lines (50 loc) 1.35 kB
const WHISPER_CPP_EXECUTE_FLAGS_OPTIONS_MAP = { threads: '-t', processors: '-p', offsetT: '-ot', offsetN: '-on', duration: '-d', maxContext: '-mc', maxLen: '-ml', splitOnWord: '-sow', bestOf: '-bo', beamSize: '-bs', wordThold: '-wt', entropyThold: '-et', logprobThold: '-lpt', debugMode: '-debug', translate: '-tr', diarize: '-di', tinydiarize: '-tdrz', noFallback: '-nf', outputTXT: '-otxt', outputVTT: '-ovtt', outputSRT: '-osrt', outputLRC: '-olrc', outputWords: '-owts', fontPath: '-fp', outputCSV: '-ocsv', outputJSON: '-oj', outputFile: '-of', printSpecial: '-ps', printColors: '-pc', printProgress: '-pp', noTimestamps: '-nt', language: '-l', detectLanguage: '-dl', prompt: '--prompt', model: '-m', file: '-f', ovEDevice: '-oved', logScore: '-ls', }; export const getWhisperCPPExecuteFlags = (options) => { return Object.entries(options).reduce((currentFlags, [key, flagValue]) => { if (flagValue === undefined || flagValue === null) { return currentFlags; } const flagOption = WHISPER_CPP_EXECUTE_FLAGS_OPTIONS_MAP[key]; currentFlags += `${currentFlags.length ? ' ' : ''}${flagOption} ${flagValue}`; return currentFlags; }, ''); };