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EAAO,MAAM,6CAA6C,MAC1D,EAAI,QAAQ,mBAAmB,GAC/B,EAAO,MAAM,mDAAmD,KAChE,MAAM,QAAuB,EAAI,QAAQ,kBAAkB,EAAU,GACrE,EAAO,MAAM,mDAAmD,KAChE,MAAM,GAAU,EAAI,gBAAgB,kBAAkB,EAAgB,GACtE,EAAO,MAAM,uCAAuC,KACpD,MAAM,QAAmB,EAAI,UAAU,mBAAmB,EAAS,EAAQ,EAAQ,UACnF,IAAK,EACD,MAAM,IAAI,MAAM,+CAMpB,OAJI,GAAmC,KAAK,QAAQ,WAAW,KAC3D,EAAO,MAAM,iDAAiD,KAC9D,KAAK,QAAQ,WAAW,IAErB,CACX,CACA,MAAO,GAEH,MADA,EAAO,MAAM,6CAA6C,EAAM,WAC1D,IAAI,MAAM,qBAAqB,EAAM,UAC/C,CACJ,GACJ","file":"/npm/@jordanburke/nodejs-whisper@0.1.23/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@jordanburke/nodejs-whisper@0.1.23/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.nodewhisper = nodewhisper;\nconst whisper_1 = require(\"./whisper\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst WhisperHelper_1 = require(\"./WhisperHelper\");\nconst utils_1 = require(\"./utils\");\nconst autoDownloadModel_1 = __importDefault(require(\"./autoDownloadModel\"));\nfunction nodewhisper(filePath, options) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const { removeWavFileAfterTranscription = false, logger = console } = options;\n        try {\n            if (options.autoDownloadModelName) {\n                logger.debug(`[Nodejs-whisper] Checking and downloading model if needed: ${options.autoDownloadModelName}`);\n                logger.debug('autoDownloadModelName', options.autoDownloadModelName);\n                logger.debug('options', options);\n                yield (0, autoDownloadModel_1.default)(logger, options.autoDownloadModelName, options.withCuda);\n            }\n            logger.debug(`[Nodejs-whisper] Checking file existence: ${filePath}`);\n            (0, utils_1.checkIfFileExists)(filePath);\n            logger.debug(`[Nodejs-whisper] Converting file to WAV format: ${filePath}`);\n            const outputFilePath = yield (0, utils_1.convertToWavType)(filePath, logger);\n            logger.debug(`[Nodejs-whisper] Constructing command for file: ${outputFilePath}`);\n            const command = (0, WhisperHelper_1.constructCommand)(outputFilePath, options);\n            logger.debug(`[Nodejs-whisper] Executing command: ${command}`);\n            const transcript = yield (0, whisper_1.executeCppCommand)(command, logger, options.withCuda);\n            if (!transcript) {\n                throw new Error('Transcription failed or produced no output.');\n            }\n            if (removeWavFileAfterTranscription && fs_1.default.existsSync(outputFilePath)) {\n                logger.debug(`[Nodejs-whisper] Removing temporary WAV file: ${outputFilePath}`);\n                fs_1.default.unlinkSync(outputFilePath);\n            }\n            return transcript;\n        }\n        catch (error) {\n            logger.error(`[Nodejs-whisper] Error during processing: ${error.message}`);\n            throw new Error(`Operation failed: ${error.message}`);\n        }\n    });\n}\n"]}