Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ricky0123/vad-web

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ricky0123/vad-web - npm Package Compare versions

Comparing version
0.0.25
to
0.0.26
+2
-2
dist/bundle.dev.js

@@ -129,3 +129,3 @@ /*

eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NonRealTimeVAD = exports.defaultNonRealTimeVADOptions = void 0;\nconst ortInstance = __importStar(__webpack_require__(/*! onnxruntime-web */ \"onnxruntime-web\"));\nconst asset_path_1 = __webpack_require__(/*! ./asset-path */ \"./dist/asset-path.js\");\nconst default_model_fetcher_1 = __webpack_require__(/*! ./default-model-fetcher */ \"./dist/default-model-fetcher.js\");\nconst frame_processor_1 = __webpack_require__(/*! ./frame-processor */ \"./dist/frame-processor.js\");\nconst messages_1 = __webpack_require__(/*! ./messages */ \"./dist/messages.js\");\nconst models_1 = __webpack_require__(/*! ./models */ \"./dist/models/index.js\");\nconst resampler_1 = __webpack_require__(/*! ./resampler */ \"./dist/resampler.js\");\nexports.defaultNonRealTimeVADOptions = {\n ...frame_processor_1.defaultLegacyFrameProcessorOptions,\n ortConfig: undefined,\n modelURL: asset_path_1.baseAssetPath + \"silero_vad_legacy.onnx\",\n modelFetcher: default_model_fetcher_1.defaultModelFetcher,\n};\nclass NonRealTimeVAD {\n static async new(options = {}) {\n const fullOptions = {\n ...exports.defaultNonRealTimeVADOptions,\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n if (fullOptions.ortConfig !== undefined) {\n fullOptions.ortConfig(ortInstance);\n }\n const modelFetcher = () => fullOptions.modelFetcher(fullOptions.modelURL);\n const model = await models_1.SileroLegacy.new(ortInstance, modelFetcher);\n const frameProcessor = new frame_processor_1.FrameProcessor(model.process, model.reset_state, {\n frameSamples: fullOptions.frameSamples,\n positiveSpeechThreshold: fullOptions.positiveSpeechThreshold,\n negativeSpeechThreshold: fullOptions.negativeSpeechThreshold,\n redemptionFrames: fullOptions.redemptionFrames,\n preSpeechPadFrames: fullOptions.preSpeechPadFrames,\n minSpeechFrames: fullOptions.minSpeechFrames,\n submitUserSpeechOnPause: fullOptions.submitUserSpeechOnPause,\n });\n frameProcessor.resume();\n const vad = new this(modelFetcher, ortInstance, fullOptions, frameProcessor);\n return vad;\n }\n constructor(modelFetcher, ort, options, frameProcessor) {\n this.modelFetcher = modelFetcher;\n this.ort = ort;\n this.options = options;\n this.frameProcessor = frameProcessor;\n }\n async *run(inputAudio, sampleRate) {\n const resamplerOptions = {\n nativeSampleRate: sampleRate,\n targetSampleRate: 16000,\n targetFrameSize: this.options.frameSamples,\n };\n const resampler = new resampler_1.Resampler(resamplerOptions);\n let start = 0;\n let end = 0;\n let frameIndex = 0;\n let messageContainer = [];\n for await (const frame of resampler.stream(inputAudio)) {\n await this.frameProcessor.process(frame, (event) => {\n messageContainer.push(event);\n });\n for (const event of messageContainer) {\n switch (event.msg) {\n case messages_1.Message.SpeechStart:\n start = (frameIndex * this.options.frameSamples) / 16;\n break;\n case messages_1.Message.SpeechEnd:\n end = ((frameIndex + 1) * this.options.frameSamples) / 16;\n yield { audio: event.audio, start, end };\n break;\n default:\n break;\n }\n }\n frameIndex++;\n }\n const { msg, audio } = this.frameProcessor.endSegment((event) => {\n messageContainer.push(event);\n });\n for (const event of messageContainer) {\n switch (event.msg) {\n case messages_1.Message.SpeechEnd:\n yield {\n audio: event.audio,\n start,\n end: (frameIndex * this.options.frameSamples) / 16,\n };\n }\n }\n }\n}\nexports.NonRealTimeVAD = NonRealTimeVAD;\n//# sourceMappingURL=non-real-time-vad.js.map\n\n//# sourceURL=webpack://vad/./dist/non-real-time-vad.js?");
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.NonRealTimeVAD = exports.defaultNonRealTimeVADOptions = void 0;\nconst ortInstance = __importStar(__webpack_require__(/*! onnxruntime-web */ \"onnxruntime-web\"));\nconst asset_path_1 = __webpack_require__(/*! ./asset-path */ \"./dist/asset-path.js\");\nconst default_model_fetcher_1 = __webpack_require__(/*! ./default-model-fetcher */ \"./dist/default-model-fetcher.js\");\nconst frame_processor_1 = __webpack_require__(/*! ./frame-processor */ \"./dist/frame-processor.js\");\nconst messages_1 = __webpack_require__(/*! ./messages */ \"./dist/messages.js\");\nconst models_1 = __webpack_require__(/*! ./models */ \"./dist/models/index.js\");\nconst resampler_1 = __webpack_require__(/*! ./resampler */ \"./dist/resampler.js\");\nexports.defaultNonRealTimeVADOptions = {\n ...frame_processor_1.defaultLegacyFrameProcessorOptions,\n ortConfig: undefined,\n modelURL: asset_path_1.baseAssetPath + \"silero_vad_legacy.onnx\",\n modelFetcher: default_model_fetcher_1.defaultModelFetcher,\n};\nclass NonRealTimeVAD {\n static async new(options = {}) {\n const fullOptions = {\n ...exports.defaultNonRealTimeVADOptions,\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n if (fullOptions.ortConfig !== undefined) {\n fullOptions.ortConfig(ortInstance);\n }\n const modelFetcher = () => fullOptions.modelFetcher(fullOptions.modelURL);\n const model = await models_1.SileroLegacy.new(ortInstance, modelFetcher);\n const frameProcessor = new frame_processor_1.FrameProcessor(model.process, model.reset_state, {\n frameSamples: fullOptions.frameSamples,\n positiveSpeechThreshold: fullOptions.positiveSpeechThreshold,\n negativeSpeechThreshold: fullOptions.negativeSpeechThreshold,\n redemptionFrames: fullOptions.redemptionFrames,\n preSpeechPadFrames: fullOptions.preSpeechPadFrames,\n minSpeechFrames: fullOptions.minSpeechFrames,\n submitUserSpeechOnPause: fullOptions.submitUserSpeechOnPause,\n });\n frameProcessor.resume();\n const vad = new this(modelFetcher, ortInstance, fullOptions, frameProcessor);\n return vad;\n }\n constructor(modelFetcher, ort, options, frameProcessor) {\n this.modelFetcher = modelFetcher;\n this.ort = ort;\n this.options = options;\n this.frameProcessor = frameProcessor;\n }\n async *run(inputAudio, sampleRate) {\n const resamplerOptions = {\n nativeSampleRate: sampleRate,\n targetSampleRate: 16000,\n targetFrameSize: this.options.frameSamples,\n };\n const resampler = new resampler_1.Resampler(resamplerOptions);\n let start = 0;\n let end = 0;\n let frameIndex = 0;\n for await (const frame of resampler.stream(inputAudio)) {\n const messageContainer = [];\n await this.frameProcessor.process(frame, (event) => {\n messageContainer.push(event);\n });\n for (const event of messageContainer) {\n switch (event.msg) {\n case messages_1.Message.SpeechStart:\n start = (frameIndex * this.options.frameSamples) / 16;\n break;\n case messages_1.Message.SpeechEnd:\n end = ((frameIndex + 1) * this.options.frameSamples) / 16;\n yield { audio: event.audio, start, end };\n break;\n default:\n break;\n }\n }\n frameIndex++;\n }\n const messageContainer = [];\n this.frameProcessor.endSegment((event) => {\n messageContainer.push(event);\n });\n for (const event of messageContainer) {\n switch (event.msg) {\n case messages_1.Message.SpeechEnd:\n yield {\n audio: event.audio,\n start,\n end: (frameIndex * this.options.frameSamples) / 16,\n };\n }\n }\n }\n}\nexports.NonRealTimeVAD = NonRealTimeVAD;\n//# sourceMappingURL=non-real-time-vad.js.map\n\n//# sourceURL=webpack://vad/./dist/non-real-time-vad.js?");

@@ -140,3 +140,3 @@ /***/ }),

eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AudioNodeVAD = exports.MicVAD = exports.getDefaultRealTimeVADOptions = exports.ort = exports.DEFAULT_MODEL = void 0;\nconst ortInstance = __importStar(__webpack_require__(/*! onnxruntime-web */ \"onnxruntime-web\"));\nconst default_model_fetcher_1 = __webpack_require__(/*! ./default-model-fetcher */ \"./dist/default-model-fetcher.js\");\nconst frame_processor_1 = __webpack_require__(/*! ./frame-processor */ \"./dist/frame-processor.js\");\nconst logging_1 = __webpack_require__(/*! ./logging */ \"./dist/logging.js\");\nconst messages_1 = __webpack_require__(/*! ./messages */ \"./dist/messages.js\");\nconst models_1 = __webpack_require__(/*! ./models */ \"./dist/models/index.js\");\nconst resampler_1 = __webpack_require__(/*! ./resampler */ \"./dist/resampler.js\");\nexports.DEFAULT_MODEL = \"legacy\";\nexports.ort = ortInstance;\nconst workletFile = \"vad.worklet.bundle.min.js\";\nconst sileroV5File = \"silero_vad_v5.onnx\";\nconst sileroLegacyFile = \"silero_vad_legacy.onnx\";\nconst getDefaultRealTimeVADOptions = (model) => {\n const frameProcessorOptions = model === \"v5\"\n ? frame_processor_1.defaultV5FrameProcessorOptions\n : frame_processor_1.defaultLegacyFrameProcessorOptions;\n return {\n ...frameProcessorOptions,\n onFrameProcessed: (probabilities, frame) => { },\n onVADMisfire: () => {\n logging_1.log.debug(\"VAD misfire\");\n },\n onSpeechStart: () => {\n logging_1.log.debug(\"Detected speech start\");\n },\n onSpeechEnd: () => {\n logging_1.log.debug(\"Detected speech end\");\n },\n onSpeechRealStart: () => {\n logging_1.log.debug(\"Detected real speech start\");\n },\n baseAssetPath: \"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@latest/dist/\",\n onnxWASMBasePath: \"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/\",\n stream: undefined,\n ortConfig: undefined,\n model: model,\n workletOptions: {},\n };\n};\nexports.getDefaultRealTimeVADOptions = getDefaultRealTimeVADOptions;\nclass MicVAD {\n static async new(options = {}) {\n const fullOptions = {\n ...(0, exports.getDefaultRealTimeVADOptions)(options.model ?? exports.DEFAULT_MODEL),\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n let stream;\n if (fullOptions.stream === undefined)\n stream = await navigator.mediaDevices.getUserMedia({\n audio: {\n ...fullOptions.additionalAudioConstraints,\n channelCount: 1,\n echoCancellation: true,\n autoGainControl: true,\n noiseSuppression: true,\n },\n });\n else\n stream = fullOptions.stream;\n const audioContext = new AudioContext();\n const sourceNode = new MediaStreamAudioSourceNode(audioContext, {\n mediaStream: stream,\n });\n const audioNodeVAD = await AudioNodeVAD.new(audioContext, fullOptions);\n audioNodeVAD.receive(sourceNode);\n return new MicVAD(fullOptions, audioContext, stream, audioNodeVAD, sourceNode);\n }\n constructor(options, audioContext, stream, audioNodeVAD, sourceNode, listening = false) {\n this.options = options;\n this.audioContext = audioContext;\n this.stream = stream;\n this.audioNodeVAD = audioNodeVAD;\n this.sourceNode = sourceNode;\n this.listening = listening;\n this.pause = () => {\n this.stream.getTracks().forEach((track) => {\n track.stop();\n });\n this.audioNodeVAD.pause();\n this.listening = false;\n };\n this.resume = async () => {\n const additionalAudioConstraints = \"additionalAudioConstraints\" in this.options\n ? this.options.additionalAudioConstraints\n : {};\n this.stream = await navigator.mediaDevices.getUserMedia({\n audio: {\n ...additionalAudioConstraints,\n channelCount: 1,\n echoCancellation: true,\n autoGainControl: true,\n noiseSuppression: true,\n },\n });\n this.sourceNode = new MediaStreamAudioSourceNode(this.audioContext, {\n mediaStream: this.stream,\n });\n this.audioNodeVAD.receive(this.sourceNode);\n };\n this.start = () => {\n if (!this.stream.active) {\n this.resume().then(() => {\n this.audioNodeVAD.start();\n this.listening = true;\n });\n }\n else {\n this.audioNodeVAD.start();\n this.listening = true;\n }\n };\n this.destroy = () => {\n if (this.listening) {\n this.pause();\n }\n if (this.options.stream === undefined) {\n this.stream.getTracks().forEach((track) => track.stop());\n }\n this.sourceNode.disconnect();\n this.audioNodeVAD.destroy();\n this.audioContext.close();\n };\n this.setOptions = (options) => {\n this.audioNodeVAD.setFrameProcessorOptions(options);\n };\n }\n}\nexports.MicVAD = MicVAD;\nclass AudioNodeVAD {\n static async new(ctx, options = {}) {\n const fullOptions = {\n ...(0, exports.getDefaultRealTimeVADOptions)(options.model ?? exports.DEFAULT_MODEL),\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n exports.ort.env.wasm.wasmPaths = fullOptions.onnxWASMBasePath;\n if (fullOptions.ortConfig !== undefined) {\n fullOptions.ortConfig(exports.ort);\n }\n const modelFile = fullOptions.model === \"v5\" ? sileroV5File : sileroLegacyFile;\n const modelURL = fullOptions.baseAssetPath + modelFile;\n const modelFactory = fullOptions.model === \"v5\" ? models_1.SileroV5.new : models_1.SileroLegacy.new;\n let model;\n try {\n model = await modelFactory(exports.ort, () => (0, default_model_fetcher_1.defaultModelFetcher)(modelURL));\n }\n catch (e) {\n console.error(`Encountered an error while loading model file ${modelURL}`);\n throw e;\n }\n const frameProcessor = new frame_processor_1.FrameProcessor(model.process, model.reset_state, {\n frameSamples: fullOptions.frameSamples,\n positiveSpeechThreshold: fullOptions.positiveSpeechThreshold,\n negativeSpeechThreshold: fullOptions.negativeSpeechThreshold,\n redemptionFrames: fullOptions.redemptionFrames,\n preSpeechPadFrames: fullOptions.preSpeechPadFrames,\n minSpeechFrames: fullOptions.minSpeechFrames,\n submitUserSpeechOnPause: fullOptions.submitUserSpeechOnPause,\n });\n const audioNodeVAD = new AudioNodeVAD(ctx, fullOptions, frameProcessor);\n await audioNodeVAD.setupAudioNode();\n return audioNodeVAD;\n }\n constructor(ctx, options, frameProcessor) {\n this.ctx = ctx;\n this.options = options;\n this.bufferIndex = 0;\n this.pause = () => {\n this.frameProcessor.pause(this.handleFrameProcessorEvent);\n };\n this.start = () => {\n this.frameProcessor.resume();\n };\n this.receive = (node) => {\n node.connect(this.audioNode);\n };\n this.processFrame = async (frame) => {\n await this.frameProcessor.process(frame, this.handleFrameProcessorEvent);\n };\n this.handleFrameProcessorEvent = (ev) => {\n switch (ev.msg) {\n case messages_1.Message.FrameProcessed:\n this.options.onFrameProcessed(ev.probs, ev.frame);\n break;\n case messages_1.Message.SpeechStart:\n this.options.onSpeechStart();\n break;\n case messages_1.Message.SpeechRealStart:\n this.options.onSpeechRealStart();\n break;\n case messages_1.Message.VADMisfire:\n this.options.onVADMisfire();\n break;\n case messages_1.Message.SpeechEnd:\n this.options.onSpeechEnd(ev.audio);\n break;\n }\n };\n this.destroy = () => {\n if (this.audioNode instanceof AudioWorkletNode) {\n this.audioNode.port.postMessage({\n message: messages_1.Message.SpeechStop,\n });\n }\n this.audioNode.disconnect();\n this.gainNode?.disconnect();\n };\n this.setFrameProcessorOptions = (options) => {\n this.frameProcessor.options = {\n ...this.frameProcessor.options,\n ...options,\n };\n };\n this.frameProcessor = frameProcessor;\n }\n async setupAudioNode() {\n const hasAudioWorklet = \"audioWorklet\" in this.ctx && typeof AudioWorkletNode === \"function\";\n if (hasAudioWorklet) {\n try {\n const workletURL = this.options.baseAssetPath + workletFile;\n await this.ctx.audioWorklet.addModule(workletURL);\n const workletOptions = this.options.workletOptions ?? {};\n workletOptions.processorOptions = {\n ...(workletOptions.processorOptions ?? {}),\n frameSamples: this.options.frameSamples,\n };\n this.audioNode = new AudioWorkletNode(this.ctx, \"vad-helper-worklet\", workletOptions);\n this.audioNode.port.onmessage = async (ev) => {\n switch (ev.data?.message) {\n case messages_1.Message.AudioFrame:\n let buffer = ev.data.data;\n if (!(buffer instanceof ArrayBuffer)) {\n buffer = new ArrayBuffer(ev.data.data.byteLength);\n new Uint8Array(buffer).set(new Uint8Array(ev.data.data));\n }\n const frame = new Float32Array(buffer);\n await this.processFrame(frame);\n break;\n }\n };\n return;\n }\n catch (e) {\n console.log(\"AudioWorklet setup failed, falling back to ScriptProcessor\", e);\n }\n }\n // Initialize resampler for ScriptProcessor\n this.resampler = new resampler_1.Resampler({\n nativeSampleRate: this.ctx.sampleRate,\n targetSampleRate: 16000,\n targetFrameSize: this.options.frameSamples ?? 480,\n });\n // Fallback to ScriptProcessor\n const bufferSize = 4096; // Increased for more stable processing\n this.audioNode = this.ctx.createScriptProcessor(bufferSize, 1, 1);\n // Create a gain node with zero gain to handle the audio chain\n this.gainNode = this.ctx.createGain();\n this.gainNode.gain.value = 0;\n let processingAudio = false;\n this.audioNode.onaudioprocess = async (e) => {\n if (processingAudio)\n return;\n processingAudio = true;\n try {\n const input = e.inputBuffer.getChannelData(0);\n const output = e.outputBuffer.getChannelData(0);\n output.fill(0);\n // Process through resampler\n if (this.resampler) {\n const frames = this.resampler.process(input);\n for (const frame of frames) {\n await this.processFrame(frame);\n }\n }\n }\n catch (error) {\n console.error(\"Error processing audio:\", error);\n }\n finally {\n processingAudio = false;\n }\n };\n // Connect the audio chain\n this.audioNode.connect(this.gainNode);\n this.gainNode.connect(this.ctx.destination);\n }\n}\nexports.AudioNodeVAD = AudioNodeVAD;\n//# sourceMappingURL=real-time-vad.js.map\n\n//# sourceURL=webpack://vad/./dist/real-time-vad.js?");
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.AudioNodeVAD = exports.MicVAD = exports.getDefaultRealTimeVADOptions = exports.ort = exports.DEFAULT_MODEL = void 0;\nconst ortInstance = __importStar(__webpack_require__(/*! onnxruntime-web */ \"onnxruntime-web\"));\nconst default_model_fetcher_1 = __webpack_require__(/*! ./default-model-fetcher */ \"./dist/default-model-fetcher.js\");\nconst frame_processor_1 = __webpack_require__(/*! ./frame-processor */ \"./dist/frame-processor.js\");\nconst logging_1 = __webpack_require__(/*! ./logging */ \"./dist/logging.js\");\nconst messages_1 = __webpack_require__(/*! ./messages */ \"./dist/messages.js\");\nconst models_1 = __webpack_require__(/*! ./models */ \"./dist/models/index.js\");\nconst resampler_1 = __webpack_require__(/*! ./resampler */ \"./dist/resampler.js\");\nexports.DEFAULT_MODEL = \"legacy\";\nexports.ort = ortInstance;\nconst workletFile = \"vad.worklet.bundle.min.js\";\nconst sileroV5File = \"silero_vad_v5.onnx\";\nconst sileroLegacyFile = \"silero_vad_legacy.onnx\";\nconst getDefaultRealTimeVADOptions = (model) => {\n const frameProcessorOptions = model === \"v5\"\n ? frame_processor_1.defaultV5FrameProcessorOptions\n : frame_processor_1.defaultLegacyFrameProcessorOptions;\n return {\n ...frameProcessorOptions,\n onFrameProcessed: (probabilities, frame) => { },\n onVADMisfire: () => {\n logging_1.log.debug(\"VAD misfire\");\n },\n onSpeechStart: () => {\n logging_1.log.debug(\"Detected speech start\");\n },\n onSpeechEnd: () => {\n logging_1.log.debug(\"Detected speech end\");\n },\n onSpeechRealStart: () => {\n logging_1.log.debug(\"Detected real speech start\");\n },\n baseAssetPath: \"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@latest/dist/\",\n onnxWASMBasePath: \"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/\",\n stream: undefined,\n ortConfig: undefined,\n model: model,\n workletOptions: {},\n };\n};\nexports.getDefaultRealTimeVADOptions = getDefaultRealTimeVADOptions;\nclass MicVAD {\n static async new(options = {}) {\n const fullOptions = {\n ...(0, exports.getDefaultRealTimeVADOptions)(options.model ?? exports.DEFAULT_MODEL),\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n let stream;\n if (fullOptions.stream === undefined)\n stream = await navigator.mediaDevices.getUserMedia({\n audio: {\n channelCount: 1,\n echoCancellation: true,\n autoGainControl: true,\n noiseSuppression: true,\n ...fullOptions.additionalAudioConstraints,\n },\n });\n else\n stream = fullOptions.stream;\n const audioContext = new AudioContext();\n const sourceNode = new MediaStreamAudioSourceNode(audioContext, {\n mediaStream: stream,\n });\n const audioNodeVAD = await AudioNodeVAD.new(audioContext, fullOptions);\n audioNodeVAD.receive(sourceNode);\n return new MicVAD(fullOptions, audioContext, stream, audioNodeVAD, sourceNode);\n }\n constructor(options, audioContext, stream, audioNodeVAD, sourceNode, listening = false) {\n this.options = options;\n this.audioContext = audioContext;\n this.stream = stream;\n this.audioNodeVAD = audioNodeVAD;\n this.sourceNode = sourceNode;\n this.listening = listening;\n this.pause = () => {\n this.stream.getTracks().forEach((track) => {\n track.stop();\n });\n this.audioNodeVAD.pause();\n this.listening = false;\n };\n this.resume = async () => {\n const additionalAudioConstraints = \"additionalAudioConstraints\" in this.options\n ? this.options.additionalAudioConstraints\n : {};\n this.stream = await navigator.mediaDevices.getUserMedia({\n audio: {\n channelCount: 1,\n echoCancellation: true,\n autoGainControl: true,\n noiseSuppression: true,\n ...additionalAudioConstraints,\n },\n });\n this.sourceNode = new MediaStreamAudioSourceNode(this.audioContext, {\n mediaStream: this.stream,\n });\n this.audioNodeVAD.receive(this.sourceNode);\n };\n this.start = () => {\n if (!this.stream.active) {\n this.resume().then(() => {\n this.audioNodeVAD.start();\n this.listening = true;\n });\n }\n else {\n this.audioNodeVAD.start();\n this.listening = true;\n }\n };\n this.destroy = () => {\n if (this.listening) {\n this.pause();\n }\n if (this.options.stream === undefined) {\n this.stream.getTracks().forEach((track) => track.stop());\n }\n this.sourceNode.disconnect();\n this.audioNodeVAD.destroy();\n this.audioContext.close();\n };\n this.setOptions = (options) => {\n this.audioNodeVAD.setFrameProcessorOptions(options);\n };\n }\n}\nexports.MicVAD = MicVAD;\nclass AudioNodeVAD {\n static async new(ctx, options = {}) {\n const fullOptions = {\n ...(0, exports.getDefaultRealTimeVADOptions)(options.model ?? exports.DEFAULT_MODEL),\n ...options,\n };\n (0, frame_processor_1.validateOptions)(fullOptions);\n exports.ort.env.wasm.wasmPaths = fullOptions.onnxWASMBasePath;\n if (fullOptions.ortConfig !== undefined) {\n fullOptions.ortConfig(exports.ort);\n }\n const modelFile = fullOptions.model === \"v5\" ? sileroV5File : sileroLegacyFile;\n const modelURL = fullOptions.baseAssetPath + modelFile;\n const modelFactory = fullOptions.model === \"v5\" ? models_1.SileroV5.new : models_1.SileroLegacy.new;\n let model;\n try {\n model = await modelFactory(exports.ort, () => (0, default_model_fetcher_1.defaultModelFetcher)(modelURL));\n }\n catch (e) {\n console.error(`Encountered an error while loading model file ${modelURL}`);\n throw e;\n }\n const frameProcessor = new frame_processor_1.FrameProcessor(model.process, model.reset_state, {\n frameSamples: fullOptions.frameSamples,\n positiveSpeechThreshold: fullOptions.positiveSpeechThreshold,\n negativeSpeechThreshold: fullOptions.negativeSpeechThreshold,\n redemptionFrames: fullOptions.redemptionFrames,\n preSpeechPadFrames: fullOptions.preSpeechPadFrames,\n minSpeechFrames: fullOptions.minSpeechFrames,\n submitUserSpeechOnPause: fullOptions.submitUserSpeechOnPause,\n });\n const audioNodeVAD = new AudioNodeVAD(ctx, fullOptions, frameProcessor);\n await audioNodeVAD.setupAudioNode();\n return audioNodeVAD;\n }\n constructor(ctx, options, frameProcessor) {\n this.ctx = ctx;\n this.options = options;\n this.bufferIndex = 0;\n this.pause = () => {\n this.frameProcessor.pause(this.handleFrameProcessorEvent);\n };\n this.start = () => {\n this.frameProcessor.resume();\n };\n this.receive = (node) => {\n node.connect(this.audioNode);\n };\n this.processFrame = async (frame) => {\n await this.frameProcessor.process(frame, this.handleFrameProcessorEvent);\n };\n this.handleFrameProcessorEvent = (ev) => {\n switch (ev.msg) {\n case messages_1.Message.FrameProcessed:\n this.options.onFrameProcessed(ev.probs, ev.frame);\n break;\n case messages_1.Message.SpeechStart:\n this.options.onSpeechStart();\n break;\n case messages_1.Message.SpeechRealStart:\n this.options.onSpeechRealStart();\n break;\n case messages_1.Message.VADMisfire:\n this.options.onVADMisfire();\n break;\n case messages_1.Message.SpeechEnd:\n this.options.onSpeechEnd(ev.audio);\n break;\n }\n };\n this.destroy = () => {\n if (this.audioNode instanceof AudioWorkletNode) {\n this.audioNode.port.postMessage({\n message: messages_1.Message.SpeechStop,\n });\n }\n this.audioNode.disconnect();\n this.gainNode?.disconnect();\n };\n this.setFrameProcessorOptions = (options) => {\n this.frameProcessor.options = {\n ...this.frameProcessor.options,\n ...options,\n };\n };\n this.frameProcessor = frameProcessor;\n }\n async setupAudioNode() {\n const hasAudioWorklet = \"audioWorklet\" in this.ctx && typeof AudioWorkletNode === \"function\";\n if (hasAudioWorklet) {\n try {\n const workletURL = this.options.baseAssetPath + workletFile;\n await this.ctx.audioWorklet.addModule(workletURL);\n const workletOptions = this.options.workletOptions ?? {};\n workletOptions.processorOptions = {\n ...(workletOptions.processorOptions ?? {}),\n frameSamples: this.options.frameSamples,\n };\n this.audioNode = new AudioWorkletNode(this.ctx, \"vad-helper-worklet\", workletOptions);\n this.audioNode.port.onmessage = async (ev) => {\n switch (ev.data?.message) {\n case messages_1.Message.AudioFrame:\n let buffer = ev.data.data;\n if (!(buffer instanceof ArrayBuffer)) {\n buffer = new ArrayBuffer(ev.data.data.byteLength);\n new Uint8Array(buffer).set(new Uint8Array(ev.data.data));\n }\n const frame = new Float32Array(buffer);\n await this.processFrame(frame);\n break;\n }\n };\n return;\n }\n catch (e) {\n console.log(\"AudioWorklet setup failed, falling back to ScriptProcessor\", e);\n }\n }\n // Initialize resampler for ScriptProcessor\n this.resampler = new resampler_1.Resampler({\n nativeSampleRate: this.ctx.sampleRate,\n targetSampleRate: 16000,\n targetFrameSize: this.options.frameSamples ?? 480,\n });\n // Fallback to ScriptProcessor\n const bufferSize = 4096; // Increased for more stable processing\n this.audioNode = this.ctx.createScriptProcessor(bufferSize, 1, 1);\n // Create a gain node with zero gain to handle the audio chain\n this.gainNode = this.ctx.createGain();\n this.gainNode.gain.value = 0;\n let processingAudio = false;\n this.audioNode.onaudioprocess = async (e) => {\n if (processingAudio)\n return;\n processingAudio = true;\n try {\n const input = e.inputBuffer.getChannelData(0);\n const output = e.outputBuffer.getChannelData(0);\n output.fill(0);\n // Process through resampler\n if (this.resampler) {\n const frames = this.resampler.process(input);\n for (const frame of frames) {\n await this.processFrame(frame);\n }\n }\n }\n catch (error) {\n console.error(\"Error processing audio:\", error);\n }\n finally {\n processingAudio = false;\n }\n };\n // Connect the audio chain\n this.audioNode.connect(this.gainNode);\n this.gainNode.connect(this.ctx.destination);\n }\n}\nexports.AudioNodeVAD = AudioNodeVAD;\n//# sourceMappingURL=real-time-vad.js.map\n\n//# sourceURL=webpack://vad/./dist/real-time-vad.js?");

@@ -143,0 +143,0 @@ /***/ }),

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("onnxruntime-web")):"function"==typeof define&&define.amd?define(["onnxruntime-web"],t):"object"==typeof exports?exports.vad=t(require("onnxruntime-web")):e.vad=t(e.ort)}(self,(e=>(()=>{"use strict";var t={485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.baseAssetPath=void 0;const s="undefined"!=typeof window&&void 0!==window.document?window.document.currentScript:null;let o="/";s&&(o=s.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),t.baseAssetPath=o},973:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultModelFetcher=void 0,t.defaultModelFetcher=e=>fetch(e).then((e=>e.arrayBuffer()))},362:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FrameProcessor=t.validateOptions=t.defaultV5FrameProcessorOptions=t.defaultLegacyFrameProcessorOptions=void 0;const o=s(710),r=s(954),i=[512,1024,1536];t.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},t.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1},t.validateOptions=function(e){i.includes(e.frameSamples)||o.log.warn("You are using an unusual frame size"),(e.positiveSpeechThreshold<0||e.positiveSpeechThreshold>1)&&o.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(e.negativeSpeechThreshold<0||e.negativeSpeechThreshold>e.positiveSpeechThreshold)&&o.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),e.preSpeechPadFrames<0&&o.log.error("preSpeechPadFrames should be positive"),e.redemptionFrames<0&&o.log.error("redemptionFrames should be positive")};const a=e=>{const t=e.reduce(((e,t)=>(e.push(e.at(-1)+t.length),e)),[0]),s=new Float32Array(t.at(-1));return e.forEach(((e,o)=>{const r=t[o];s.set(e,r)})),s};t.FrameProcessor=class{constructor(e,t,s){this.modelProcessFunc=e,this.modelResetFunc=t,this.options=s,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=e=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(e):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=e=>{const t=this.audioBuffer;this.audioBuffer=[];const s=this.speaking;if(this.reset(),s)if(t.reduce(((e,t)=>t.isSpeech?e+1:e),0)>=this.options.minSpeechFrames){const s=a(t.map((e=>e.frame)));e({msg:r.Message.SpeechEnd,audio:s})}else e({msg:r.Message.VADMisfire});return{}},this.process=async(e,t)=>{if(!this.active)return;const s=await this.modelProcessFunc(e),o=s.isSpeech>=this.options.positiveSpeechThreshold;if(t({probs:s,msg:r.Message.FrameProcessed,frame:e}),this.audioBuffer.push({frame:e,isSpeech:o}),o&&(this.speechFrameCount++,this.redemptionCounter=0),o&&!this.speaking&&(this.speaking=!0,t({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.options.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,t({msg:r.Message.SpeechRealStart})),s.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.options.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const e=this.audioBuffer;if(this.audioBuffer=[],e.reduce(((e,t)=>t.isSpeech?e+1:e),0)>=this.options.minSpeechFrames){const s=a(e.map((e=>e.frame)));t({msg:r.Message.SpeechEnd,audio:s})}else t({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[],this.reset()}}},710:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.log=t.LOG_PREFIX=void 0,t.LOG_PREFIX="[VAD]";const s=["error","debug","warn"].reduce(((e,s)=>(e[s]=function(e){return(...s)=>{console[e](t.LOG_PREFIX,...s)}}(s),e)),{});t.log=s},954:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.Message=void 0,function(e){e.AudioFrame="AUDIO_FRAME",e.SpeechStart="SPEECH_START",e.VADMisfire="VAD_MISFIRE",e.SpeechEnd="SPEECH_END",e.SpeechStop="SPEECH_STOP",e.SpeechRealStart="SPEECH_REAL_START",e.FrameProcessed="FRAME_PROCESSED"}(s||(t.Message=s={}))},650:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},559:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||o(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.SileroV5=t.SileroLegacy=void 0,r(s(650),t);var i=s(143);Object.defineProperty(t,"SileroLegacy",{enumerable:!0,get:function(){return i.SileroLegacy}});var a=s(508);Object.defineProperty(t,"SileroV5",{enumerable:!0,get:function(){return a.SileroV5}})},143:(e,t,s)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.SileroLegacy=void 0;const r=s(710);class i{constructor(e,t,s,o,r){this.ortInstance=e,this._session=t,this._h=s,this._c=o,this._sr=r,this.reset_state=()=>{const e=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",e,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",e,[2,1,64])},this.process=async e=>{const t={input:new this.ortInstance.Tensor("float32",e,[1,e.length]),h:this._h,c:this._c,sr:this._sr},s=await this._session.run(t);this._h=s.hn,this._c=s.cn;const[o]=s.output?.data;return{notSpeech:1-o,isSpeech:o}}}}t.SileroLegacy=i,o=i,i.new=async(e,t)=>{r.log.debug("initializing vad");const s=await t(),i=await e.InferenceSession.create(s),a=new e.Tensor("int64",[16000n]),n=Array(128).fill(0),c=new e.Tensor("float32",n,[2,1,64]),h=new e.Tensor("float32",n,[2,1,64]);return r.log.debug("vad is initialized"),new o(e,i,c,h,a)}},508:(e,t,s)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.SileroV5=void 0;const r=s(710);function i(e){const t=Array(256).fill(0);return new e.Tensor("float32",t,[2,1,128])}class a{constructor(e,t,s,o){this._session=e,this._state=t,this._sr=s,this.ortInstance=o,this.reset_state=()=>{this._state=i(this.ortInstance)},this.process=async e=>{const t={input:new this.ortInstance.Tensor("float32",e,[1,e.length]),state:this._state,sr:this._sr},s=await this._session.run(t);this._state=s.stateN;const[o]=s.output?.data;return{notSpeech:1-o,isSpeech:o}}}}t.SileroV5=a,o=a,a.new=async(e,t)=>{r.log.debug("Loading VAD...");const s=await t(),a=await e.InferenceSession.create(s),n=new e.Tensor("int64",[16000n]),c=i(e);return r.log.debug("...finished loading VAD"),new o(a,c,n,e)}},202:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&o(t,e,s);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.NonRealTimeVAD=t.defaultNonRealTimeVADOptions=void 0;const a=i(s(656)),n=s(485),c=s(973),h=s(362),d=s(954),u=s(559),l=s(825);t.defaultNonRealTimeVADOptions={...h.defaultLegacyFrameProcessorOptions,ortConfig:void 0,modelURL:n.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:c.defaultModelFetcher},t.NonRealTimeVAD=class{static async new(e={}){const s={...t.defaultNonRealTimeVADOptions,...e};(0,h.validateOptions)(s),void 0!==s.ortConfig&&s.ortConfig(a);const o=()=>s.modelFetcher(s.modelURL),r=await u.SileroLegacy.new(a,o),i=new h.FrameProcessor(r.process,r.reset_state,{frameSamples:s.frameSamples,positiveSpeechThreshold:s.positiveSpeechThreshold,negativeSpeechThreshold:s.negativeSpeechThreshold,redemptionFrames:s.redemptionFrames,preSpeechPadFrames:s.preSpeechPadFrames,minSpeechFrames:s.minSpeechFrames,submitUserSpeechOnPause:s.submitUserSpeechOnPause});return i.resume(),new this(o,a,s,i)}constructor(e,t,s,o){this.modelFetcher=e,this.ort=t,this.options=s,this.frameProcessor=o}async*run(e,t){const s={nativeSampleRate:t,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},o=new l.Resampler(s);let r=0,i=0,a=0,n=[];for await(const t of o.stream(e)){await this.frameProcessor.process(t,(e=>{n.push(e)}));for(const e of n)switch(e.msg){case d.Message.SpeechStart:r=a*this.options.frameSamples/16;break;case d.Message.SpeechEnd:i=(a+1)*this.options.frameSamples/16,yield{audio:e.audio,start:r,end:i}}a++}const{msg:c,audio:h}=this.frameProcessor.endSegment((e=>{n.push(e)}));for(const e of n)e.msg===d.Message.SpeechEnd&&(yield{audio:e.audio,start:r,end:a*this.options.frameSamples/16})}}},746:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&o(t,e,s);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.AudioNodeVAD=t.MicVAD=t.getDefaultRealTimeVADOptions=t.ort=t.DEFAULT_MODEL=void 0;const a=i(s(656)),n=s(973),c=s(362),h=s(710),d=s(954),u=s(559),l=s(825);t.DEFAULT_MODEL="legacy",t.ort=a,t.getDefaultRealTimeVADOptions=e=>({..."v5"===e?c.defaultV5FrameProcessorOptions:c.defaultLegacyFrameProcessorOptions,onFrameProcessed:(e,t)=>{},onVADMisfire:()=>{h.log.debug("VAD misfire")},onSpeechStart:()=>{h.log.debug("Detected speech start")},onSpeechEnd:()=>{h.log.debug("Detected speech end")},onSpeechRealStart:()=>{h.log.debug("Detected real speech start")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@latest/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:e,workletOptions:{}});class p{static async new(e={}){const s={...(0,t.getDefaultRealTimeVADOptions)(e.model??t.DEFAULT_MODEL),...e};let o;(0,c.validateOptions)(s),o=void 0===s.stream?await navigator.mediaDevices.getUserMedia({audio:{...s.additionalAudioConstraints,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}):s.stream;const r=new AudioContext,i=new MediaStreamAudioSourceNode(r,{mediaStream:o}),a=await f.new(r,s);return a.receive(i),new p(s,r,o,a,i)}constructor(e,t,s,o,r,i=!1){this.options=e,this.audioContext=t,this.stream=s,this.audioNodeVAD=o,this.sourceNode=r,this.listening=i,this.pause=()=>{this.stream.getTracks().forEach((e=>{e.stop()})),this.audioNodeVAD.pause(),this.listening=!1},this.resume=async()=>{const e="additionalAudioConstraints"in this.options?this.options.additionalAudioConstraints:{};this.stream=await navigator.mediaDevices.getUserMedia({audio:{...e,channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),this.sourceNode=new MediaStreamAudioSourceNode(this.audioContext,{mediaStream:this.stream}),this.audioNodeVAD.receive(this.sourceNode)},this.start=()=>{this.stream.active?(this.audioNodeVAD.start(),this.listening=!0):this.resume().then((()=>{this.audioNodeVAD.start(),this.listening=!0}))},this.destroy=()=>{this.listening&&this.pause(),void 0===this.options.stream&&this.stream.getTracks().forEach((e=>e.stop())),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()},this.setOptions=e=>{this.audioNodeVAD.setFrameProcessorOptions(e)}}}t.MicVAD=p;class f{static async new(e,s={}){const o={...(0,t.getDefaultRealTimeVADOptions)(s.model??t.DEFAULT_MODEL),...s};(0,c.validateOptions)(o),t.ort.env.wasm.wasmPaths=o.onnxWASMBasePath,void 0!==o.ortConfig&&o.ortConfig(t.ort);const r="v5"===o.model?"silero_vad_v5.onnx":"silero_vad_legacy.onnx",i=o.baseAssetPath+r,a="v5"===o.model?u.SileroV5.new:u.SileroLegacy.new;let h;try{h=await a(t.ort,(()=>(0,n.defaultModelFetcher)(i)))}catch(e){throw console.error(`Encountered an error while loading model file ${i}`),e}const d=new c.FrameProcessor(h.process,h.reset_state,{frameSamples:o.frameSamples,positiveSpeechThreshold:o.positiveSpeechThreshold,negativeSpeechThreshold:o.negativeSpeechThreshold,redemptionFrames:o.redemptionFrames,preSpeechPadFrames:o.preSpeechPadFrames,minSpeechFrames:o.minSpeechFrames,submitUserSpeechOnPause:o.submitUserSpeechOnPause}),l=new f(e,o,d);return await l.setupAudioNode(),l}constructor(e,t,s){this.ctx=e,this.options=t,this.bufferIndex=0,this.pause=()=>{this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.start=()=>{this.frameProcessor.resume()},this.receive=e=>{e.connect(this.audioNode)},this.processFrame=async e=>{await this.frameProcessor.process(e,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=e=>{switch(e.msg){case d.Message.FrameProcessed:this.options.onFrameProcessed(e.probs,e.frame);break;case d.Message.SpeechStart:this.options.onSpeechStart();break;case d.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case d.Message.VADMisfire:this.options.onVADMisfire();break;case d.Message.SpeechEnd:this.options.onSpeechEnd(e.audio)}},this.destroy=()=>{this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:d.Message.SpeechStop}),this.audioNode.disconnect(),this.gainNode?.disconnect()},this.setFrameProcessorOptions=e=>{this.frameProcessor.options={...this.frameProcessor.options,...e}},this.frameProcessor=s}async setupAudioNode(){if("audioWorklet"in this.ctx&&"function"==typeof AudioWorkletNode)try{const e=this.options.baseAssetPath+"vad.worklet.bundle.min.js";await this.ctx.audioWorklet.addModule(e);const t=this.options.workletOptions??{};return t.processorOptions={...t.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",t),void(this.audioNode.port.onmessage=async e=>{if(e.data?.message===d.Message.AudioFrame){let t=e.data.data;t instanceof ArrayBuffer||(t=new ArrayBuffer(e.data.data.byteLength),new Uint8Array(t).set(new Uint8Array(e.data.data)));const s=new Float32Array(t);await this.processFrame(s)}})}catch(e){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",e)}this.resampler=new l.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480}),this.audioNode=this.ctx.createScriptProcessor(4096,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let e=!1;this.audioNode.onaudioprocess=async t=>{if(!e){e=!0;try{const e=t.inputBuffer.getChannelData(0);if(t.outputBuffer.getChannelData(0).fill(0),this.resampler){const t=this.resampler.process(e);for(const e of t)await this.processFrame(e)}}catch(e){console.error("Error processing audio:",e)}finally{e=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}t.AudioNodeVAD=f},825:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Resampler=void 0;const o=s(710);t.Resampler=class{constructor(e){this.options=e,this.process=e=>{const t=[];for(const s of e)for(this.inputBuffer.push(s);this.hasEnoughDataForFrame();){const e=this.generateOutputFrame();t.push(e)}return t},e.nativeSampleRate<16e3&&o.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}async*stream(e){for(const t of e)for(this.inputBuffer.push(t);this.hasEnoughDataForFrame();){const e=this.generateOutputFrame();yield e}}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const e=new Float32Array(this.options.targetFrameSize);let t=0,s=0;for(;t<this.options.targetFrameSize;){let o=0,r=0;for(;s<Math.min(this.inputBuffer.length,(t+1)*this.options.nativeSampleRate/this.options.targetSampleRate);){const e=this.inputBuffer[s];void 0!==e&&(o+=e,r++),s++}e[t]=o/r,t++}return this.inputBuffer=this.inputBuffer.slice(s),e}}},787:(e,t)=>{function s(e,t,s){for(var o=0;o<s.length;o++)e.setUint8(t+o,s.charCodeAt(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.audioFileToArray=t.encodeWAV=t.arrayBufferToBase64=t.minFramesForTargetMS=void 0,t.minFramesForTargetMS=function(e,t,s=16e3){return Math.ceil(e*s/1e3/t)},t.arrayBufferToBase64=function(e){const t=new Uint8Array(e),s=t.byteLength,o=new Array(s);for(var r=0;r<s;r++){const e=t[r];if(void 0===e)break;o[r]=String.fromCharCode(e)}return btoa(o.join(""))},t.encodeWAV=function(e,t=3,o=16e3,r=1,i=32){var a=i/8,n=r*a,c=new ArrayBuffer(44+e.length*a),h=new DataView(c);return s(h,0,"RIFF"),h.setUint32(4,36+e.length*a,!0),s(h,8,"WAVE"),s(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,t,!0),h.setUint16(22,r,!0),h.setUint32(24,o,!0),h.setUint32(28,o*n,!0),h.setUint16(32,n,!0),h.setUint16(34,i,!0),s(h,36,"data"),h.setUint32(40,e.length*a,!0),1===t?function(e,t,s){for(var o=0;o<s.length;o++,t+=2){var r=Math.max(-1,Math.min(1,s[o]));e.setInt16(t,r<0?32768*r:32767*r,!0)}}(h,44,e):function(e,t,s){for(var o=0;o<s.length;o++,t+=4)e.setFloat32(t,s[o],!0)}(h,44,e),c},t.audioFileToArray=async function(e){const t=new OfflineAudioContext(1,1,44100),s=new FileReader;let o=null;if(await new Promise((r=>{s.addEventListener("loadend",(e=>{const i=s.result;t.decodeAudioData(i,(e=>{o=e,t.startRendering().then((e=>{console.log("Rendering completed successfully"),r()})).catch((e=>{console.error(`Rendering failed: ${e}`)}))}),(e=>{console.log(`Error with decoding audio data: ${e}`)}))})),s.readAsArrayBuffer(e)})),null===o)throw Error("some shit");let r=o,i=new Float32Array(r.length);for(let e=0;e<r.length;e++)for(let t=0;t<r.numberOfChannels;t++)i[e]+=r.getChannelData(t)[e];return{audio:i,sampleRate:r.sampleRate}}},656:t=>{t.exports=e}},s={};function o(e){var r=s[e];if(void 0!==r)return r.exports;var i=s[e]={exports:{}};return t[e].call(i.exports,i,i.exports,o),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.AudioNodeVAD=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var t=o(485);Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return t.baseAssetPath}});var s=o(973);Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return s.defaultModelFetcher}});var i=o(362);Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var a=o(954);Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return a.Message}});var n=o(202);Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return n.NonRealTimeVAD}});const c=o(787);e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var h=o(746);Object.defineProperty(e,"AudioNodeVAD",{enumerable:!0,get:function(){return h.AudioNodeVAD}}),Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return h.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return h.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return h.getDefaultRealTimeVADOptions}})})(),r})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("onnxruntime-web")):"function"==typeof define&&define.amd?define(["onnxruntime-web"],t):"object"==typeof exports?exports.vad=t(require("onnxruntime-web")):e.vad=t(e.ort)}(self,(e=>(()=>{"use strict";var t={485:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.baseAssetPath=void 0;const s="undefined"!=typeof window&&void 0!==window.document?window.document.currentScript:null;let o="/";s&&(o=s.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),t.baseAssetPath=o},973:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultModelFetcher=void 0,t.defaultModelFetcher=e=>fetch(e).then((e=>e.arrayBuffer()))},362:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FrameProcessor=t.validateOptions=t.defaultV5FrameProcessorOptions=t.defaultLegacyFrameProcessorOptions=void 0;const o=s(710),r=s(954),i=[512,1024,1536];t.defaultLegacyFrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,preSpeechPadFrames:1,redemptionFrames:8,frameSamples:1536,minSpeechFrames:3,submitUserSpeechOnPause:!1},t.defaultV5FrameProcessorOptions={positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,preSpeechPadFrames:3,redemptionFrames:24,frameSamples:512,minSpeechFrames:9,submitUserSpeechOnPause:!1},t.validateOptions=function(e){i.includes(e.frameSamples)||o.log.warn("You are using an unusual frame size"),(e.positiveSpeechThreshold<0||e.positiveSpeechThreshold>1)&&o.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(e.negativeSpeechThreshold<0||e.negativeSpeechThreshold>e.positiveSpeechThreshold)&&o.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),e.preSpeechPadFrames<0&&o.log.error("preSpeechPadFrames should be positive"),e.redemptionFrames<0&&o.log.error("redemptionFrames should be positive")};const a=e=>{const t=e.reduce(((e,t)=>(e.push(e.at(-1)+t.length),e)),[0]),s=new Float32Array(t.at(-1));return e.forEach(((e,o)=>{const r=t[o];s.set(e,r)})),s};t.FrameProcessor=class{constructor(e,t,s){this.modelProcessFunc=e,this.modelResetFunc=t,this.options=s,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=e=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(e):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=e=>{const t=this.audioBuffer;this.audioBuffer=[];const s=this.speaking;if(this.reset(),s)if(t.reduce(((e,t)=>t.isSpeech?e+1:e),0)>=this.options.minSpeechFrames){const s=a(t.map((e=>e.frame)));e({msg:r.Message.SpeechEnd,audio:s})}else e({msg:r.Message.VADMisfire});return{}},this.process=async(e,t)=>{if(!this.active)return;const s=await this.modelProcessFunc(e),o=s.isSpeech>=this.options.positiveSpeechThreshold;if(t({probs:s,msg:r.Message.FrameProcessed,frame:e}),this.audioBuffer.push({frame:e,isSpeech:o}),o&&(this.speechFrameCount++,this.redemptionCounter=0),o&&!this.speaking&&(this.speaking=!0,t({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.options.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,t({msg:r.Message.SpeechRealStart})),s.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.options.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const e=this.audioBuffer;if(this.audioBuffer=[],e.reduce(((e,t)=>t.isSpeech?e+1:e),0)>=this.options.minSpeechFrames){const s=a(e.map((e=>e.frame)));t({msg:r.Message.SpeechEnd,audio:s})}else t({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.options.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[],this.reset()}}},710:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.log=t.LOG_PREFIX=void 0,t.LOG_PREFIX="[VAD]";const s=["error","debug","warn"].reduce(((e,s)=>(e[s]=function(e){return(...s)=>{console[e](t.LOG_PREFIX,...s)}}(s),e)),{});t.log=s},954:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.Message=void 0,function(e){e.AudioFrame="AUDIO_FRAME",e.SpeechStart="SPEECH_START",e.VADMisfire="VAD_MISFIRE",e.SpeechEnd="SPEECH_END",e.SpeechStop="SPEECH_STOP",e.SpeechRealStart="SPEECH_REAL_START",e.FrameProcessed="FRAME_PROCESSED"}(s||(t.Message=s={}))},650:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},559:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||o(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),t.SileroV5=t.SileroLegacy=void 0,r(s(650),t);var i=s(143);Object.defineProperty(t,"SileroLegacy",{enumerable:!0,get:function(){return i.SileroLegacy}});var a=s(508);Object.defineProperty(t,"SileroV5",{enumerable:!0,get:function(){return a.SileroV5}})},143:(e,t,s)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.SileroLegacy=void 0;const r=s(710);class i{constructor(e,t,s,o,r){this.ortInstance=e,this._session=t,this._h=s,this._c=o,this._sr=r,this.reset_state=()=>{const e=Array(128).fill(0);this._h=new this.ortInstance.Tensor("float32",e,[2,1,64]),this._c=new this.ortInstance.Tensor("float32",e,[2,1,64])},this.process=async e=>{const t={input:new this.ortInstance.Tensor("float32",e,[1,e.length]),h:this._h,c:this._c,sr:this._sr},s=await this._session.run(t);this._h=s.hn,this._c=s.cn;const[o]=s.output?.data;return{notSpeech:1-o,isSpeech:o}}}}t.SileroLegacy=i,o=i,i.new=async(e,t)=>{r.log.debug("initializing vad");const s=await t(),i=await e.InferenceSession.create(s),a=new e.Tensor("int64",[16000n]),n=Array(128).fill(0),c=new e.Tensor("float32",n,[2,1,64]),h=new e.Tensor("float32",n,[2,1,64]);return r.log.debug("vad is initialized"),new o(e,i,c,h,a)}},508:(e,t,s)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.SileroV5=void 0;const r=s(710);function i(e){const t=Array(256).fill(0);return new e.Tensor("float32",t,[2,1,128])}class a{constructor(e,t,s,o){this._session=e,this._state=t,this._sr=s,this.ortInstance=o,this.reset_state=()=>{this._state=i(this.ortInstance)},this.process=async e=>{const t={input:new this.ortInstance.Tensor("float32",e,[1,e.length]),state:this._state,sr:this._sr},s=await this._session.run(t);this._state=s.stateN;const[o]=s.output?.data;return{notSpeech:1-o,isSpeech:o}}}}t.SileroV5=a,o=a,a.new=async(e,t)=>{r.log.debug("Loading VAD...");const s=await t(),a=await e.InferenceSession.create(s),n=new e.Tensor("int64",[16000n]),c=i(e);return r.log.debug("...finished loading VAD"),new o(a,c,n,e)}},202:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&o(t,e,s);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.NonRealTimeVAD=t.defaultNonRealTimeVADOptions=void 0;const a=i(s(656)),n=s(485),c=s(973),h=s(362),d=s(954),u=s(559),l=s(825);t.defaultNonRealTimeVADOptions={...h.defaultLegacyFrameProcessorOptions,ortConfig:void 0,modelURL:n.baseAssetPath+"silero_vad_legacy.onnx",modelFetcher:c.defaultModelFetcher},t.NonRealTimeVAD=class{static async new(e={}){const s={...t.defaultNonRealTimeVADOptions,...e};(0,h.validateOptions)(s),void 0!==s.ortConfig&&s.ortConfig(a);const o=()=>s.modelFetcher(s.modelURL),r=await u.SileroLegacy.new(a,o),i=new h.FrameProcessor(r.process,r.reset_state,{frameSamples:s.frameSamples,positiveSpeechThreshold:s.positiveSpeechThreshold,negativeSpeechThreshold:s.negativeSpeechThreshold,redemptionFrames:s.redemptionFrames,preSpeechPadFrames:s.preSpeechPadFrames,minSpeechFrames:s.minSpeechFrames,submitUserSpeechOnPause:s.submitUserSpeechOnPause});return i.resume(),new this(o,a,s,i)}constructor(e,t,s,o){this.modelFetcher=e,this.ort=t,this.options=s,this.frameProcessor=o}async*run(e,t){const s={nativeSampleRate:t,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples},o=new l.Resampler(s);let r=0,i=0,a=0;for await(const t of o.stream(e)){const e=[];await this.frameProcessor.process(t,(t=>{e.push(t)}));for(const t of e)switch(t.msg){case d.Message.SpeechStart:r=a*this.options.frameSamples/16;break;case d.Message.SpeechEnd:i=(a+1)*this.options.frameSamples/16,yield{audio:t.audio,start:r,end:i}}a++}const n=[];this.frameProcessor.endSegment((e=>{n.push(e)}));for(const e of n)e.msg===d.Message.SpeechEnd&&(yield{audio:e.audio,start:r,end:a*this.options.frameSamples/16})}}},746:function(e,t,s){var o=this&&this.__createBinding||(Object.create?function(e,t,s,o){void 0===o&&(o=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,o,r)}:function(e,t,s,o){void 0===o&&(o=s),e[o]=t[s]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&o(t,e,s);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.AudioNodeVAD=t.MicVAD=t.getDefaultRealTimeVADOptions=t.ort=t.DEFAULT_MODEL=void 0;const a=i(s(656)),n=s(973),c=s(362),h=s(710),d=s(954),u=s(559),l=s(825);t.DEFAULT_MODEL="legacy",t.ort=a,t.getDefaultRealTimeVADOptions=e=>({..."v5"===e?c.defaultV5FrameProcessorOptions:c.defaultLegacyFrameProcessorOptions,onFrameProcessed:(e,t)=>{},onVADMisfire:()=>{h.log.debug("VAD misfire")},onSpeechStart:()=>{h.log.debug("Detected speech start")},onSpeechEnd:()=>{h.log.debug("Detected speech end")},onSpeechRealStart:()=>{h.log.debug("Detected real speech start")},baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@latest/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.14.0/dist/",stream:void 0,ortConfig:void 0,model:e,workletOptions:{}});class p{static async new(e={}){const s={...(0,t.getDefaultRealTimeVADOptions)(e.model??t.DEFAULT_MODEL),...e};let o;(0,c.validateOptions)(s),o=void 0===s.stream?await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,...s.additionalAudioConstraints}}):s.stream;const r=new AudioContext,i=new MediaStreamAudioSourceNode(r,{mediaStream:o}),a=await f.new(r,s);return a.receive(i),new p(s,r,o,a,i)}constructor(e,t,s,o,r,i=!1){this.options=e,this.audioContext=t,this.stream=s,this.audioNodeVAD=o,this.sourceNode=r,this.listening=i,this.pause=()=>{this.stream.getTracks().forEach((e=>{e.stop()})),this.audioNodeVAD.pause(),this.listening=!1},this.resume=async()=>{const e="additionalAudioConstraints"in this.options?this.options.additionalAudioConstraints:{};this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,...e}}),this.sourceNode=new MediaStreamAudioSourceNode(this.audioContext,{mediaStream:this.stream}),this.audioNodeVAD.receive(this.sourceNode)},this.start=()=>{this.stream.active?(this.audioNodeVAD.start(),this.listening=!0):this.resume().then((()=>{this.audioNodeVAD.start(),this.listening=!0}))},this.destroy=()=>{this.listening&&this.pause(),void 0===this.options.stream&&this.stream.getTracks().forEach((e=>e.stop())),this.sourceNode.disconnect(),this.audioNodeVAD.destroy(),this.audioContext.close()},this.setOptions=e=>{this.audioNodeVAD.setFrameProcessorOptions(e)}}}t.MicVAD=p;class f{static async new(e,s={}){const o={...(0,t.getDefaultRealTimeVADOptions)(s.model??t.DEFAULT_MODEL),...s};(0,c.validateOptions)(o),t.ort.env.wasm.wasmPaths=o.onnxWASMBasePath,void 0!==o.ortConfig&&o.ortConfig(t.ort);const r="v5"===o.model?"silero_vad_v5.onnx":"silero_vad_legacy.onnx",i=o.baseAssetPath+r,a="v5"===o.model?u.SileroV5.new:u.SileroLegacy.new;let h;try{h=await a(t.ort,(()=>(0,n.defaultModelFetcher)(i)))}catch(e){throw console.error(`Encountered an error while loading model file ${i}`),e}const d=new c.FrameProcessor(h.process,h.reset_state,{frameSamples:o.frameSamples,positiveSpeechThreshold:o.positiveSpeechThreshold,negativeSpeechThreshold:o.negativeSpeechThreshold,redemptionFrames:o.redemptionFrames,preSpeechPadFrames:o.preSpeechPadFrames,minSpeechFrames:o.minSpeechFrames,submitUserSpeechOnPause:o.submitUserSpeechOnPause}),l=new f(e,o,d);return await l.setupAudioNode(),l}constructor(e,t,s){this.ctx=e,this.options=t,this.bufferIndex=0,this.pause=()=>{this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.start=()=>{this.frameProcessor.resume()},this.receive=e=>{e.connect(this.audioNode)},this.processFrame=async e=>{await this.frameProcessor.process(e,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=e=>{switch(e.msg){case d.Message.FrameProcessed:this.options.onFrameProcessed(e.probs,e.frame);break;case d.Message.SpeechStart:this.options.onSpeechStart();break;case d.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case d.Message.VADMisfire:this.options.onVADMisfire();break;case d.Message.SpeechEnd:this.options.onSpeechEnd(e.audio)}},this.destroy=()=>{this.audioNode instanceof AudioWorkletNode&&this.audioNode.port.postMessage({message:d.Message.SpeechStop}),this.audioNode.disconnect(),this.gainNode?.disconnect()},this.setFrameProcessorOptions=e=>{this.frameProcessor.options={...this.frameProcessor.options,...e}},this.frameProcessor=s}async setupAudioNode(){if("audioWorklet"in this.ctx&&"function"==typeof AudioWorkletNode)try{const e=this.options.baseAssetPath+"vad.worklet.bundle.min.js";await this.ctx.audioWorklet.addModule(e);const t=this.options.workletOptions??{};return t.processorOptions={...t.processorOptions??{},frameSamples:this.options.frameSamples},this.audioNode=new AudioWorkletNode(this.ctx,"vad-helper-worklet",t),void(this.audioNode.port.onmessage=async e=>{if(e.data?.message===d.Message.AudioFrame){let t=e.data.data;t instanceof ArrayBuffer||(t=new ArrayBuffer(e.data.data.byteLength),new Uint8Array(t).set(new Uint8Array(e.data.data)));const s=new Float32Array(t);await this.processFrame(s)}})}catch(e){console.log("AudioWorklet setup failed, falling back to ScriptProcessor",e)}this.resampler=new l.Resampler({nativeSampleRate:this.ctx.sampleRate,targetSampleRate:16e3,targetFrameSize:this.options.frameSamples??480}),this.audioNode=this.ctx.createScriptProcessor(4096,1,1),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=0;let e=!1;this.audioNode.onaudioprocess=async t=>{if(!e){e=!0;try{const e=t.inputBuffer.getChannelData(0);if(t.outputBuffer.getChannelData(0).fill(0),this.resampler){const t=this.resampler.process(e);for(const e of t)await this.processFrame(e)}}catch(e){console.error("Error processing audio:",e)}finally{e=!1}}},this.audioNode.connect(this.gainNode),this.gainNode.connect(this.ctx.destination)}}t.AudioNodeVAD=f},825:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Resampler=void 0;const o=s(710);t.Resampler=class{constructor(e){this.options=e,this.process=e=>{const t=[];for(const s of e)for(this.inputBuffer.push(s);this.hasEnoughDataForFrame();){const e=this.generateOutputFrame();t.push(e)}return t},e.nativeSampleRate<16e3&&o.log.error("nativeSampleRate is too low. Should have 16000 = targetSampleRate <= nativeSampleRate"),this.inputBuffer=[]}async*stream(e){for(const t of e)for(this.inputBuffer.push(t);this.hasEnoughDataForFrame();){const e=this.generateOutputFrame();yield e}}hasEnoughDataForFrame(){return this.inputBuffer.length*this.options.targetSampleRate/this.options.nativeSampleRate>=this.options.targetFrameSize}generateOutputFrame(){const e=new Float32Array(this.options.targetFrameSize);let t=0,s=0;for(;t<this.options.targetFrameSize;){let o=0,r=0;for(;s<Math.min(this.inputBuffer.length,(t+1)*this.options.nativeSampleRate/this.options.targetSampleRate);){const e=this.inputBuffer[s];void 0!==e&&(o+=e,r++),s++}e[t]=o/r,t++}return this.inputBuffer=this.inputBuffer.slice(s),e}}},787:(e,t)=>{function s(e,t,s){for(var o=0;o<s.length;o++)e.setUint8(t+o,s.charCodeAt(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.audioFileToArray=t.encodeWAV=t.arrayBufferToBase64=t.minFramesForTargetMS=void 0,t.minFramesForTargetMS=function(e,t,s=16e3){return Math.ceil(e*s/1e3/t)},t.arrayBufferToBase64=function(e){const t=new Uint8Array(e),s=t.byteLength,o=new Array(s);for(var r=0;r<s;r++){const e=t[r];if(void 0===e)break;o[r]=String.fromCharCode(e)}return btoa(o.join(""))},t.encodeWAV=function(e,t=3,o=16e3,r=1,i=32){var a=i/8,n=r*a,c=new ArrayBuffer(44+e.length*a),h=new DataView(c);return s(h,0,"RIFF"),h.setUint32(4,36+e.length*a,!0),s(h,8,"WAVE"),s(h,12,"fmt "),h.setUint32(16,16,!0),h.setUint16(20,t,!0),h.setUint16(22,r,!0),h.setUint32(24,o,!0),h.setUint32(28,o*n,!0),h.setUint16(32,n,!0),h.setUint16(34,i,!0),s(h,36,"data"),h.setUint32(40,e.length*a,!0),1===t?function(e,t,s){for(var o=0;o<s.length;o++,t+=2){var r=Math.max(-1,Math.min(1,s[o]));e.setInt16(t,r<0?32768*r:32767*r,!0)}}(h,44,e):function(e,t,s){for(var o=0;o<s.length;o++,t+=4)e.setFloat32(t,s[o],!0)}(h,44,e),c},t.audioFileToArray=async function(e){const t=new OfflineAudioContext(1,1,44100),s=new FileReader;let o=null;if(await new Promise((r=>{s.addEventListener("loadend",(e=>{const i=s.result;t.decodeAudioData(i,(e=>{o=e,t.startRendering().then((e=>{console.log("Rendering completed successfully"),r()})).catch((e=>{console.error(`Rendering failed: ${e}`)}))}),(e=>{console.log(`Error with decoding audio data: ${e}`)}))})),s.readAsArrayBuffer(e)})),null===o)throw Error("some shit");let r=o,i=new Float32Array(r.length);for(let e=0;e<r.length;e++)for(let t=0;t<r.numberOfChannels;t++)i[e]+=r.getChannelData(t)[e];return{audio:i,sampleRate:r.sampleRate}}},656:t=>{t.exports=e}},s={};function o(e){var r=s[e];if(void 0!==r)return r.exports;var i=s[e]={exports:{}};return t[e].call(i.exports,i,i.exports,o),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.AudioNodeVAD=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var t=o(485);Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return t.baseAssetPath}});var s=o(973);Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return s.defaultModelFetcher}});var i=o(362);Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var a=o(954);Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return a.Message}});var n=o(202);Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return n.NonRealTimeVAD}});const c=o(787);e.utils={audioFileToArray:c.audioFileToArray,minFramesForTargetMS:c.minFramesForTargetMS,arrayBufferToBase64:c.arrayBufferToBase64,encodeWAV:c.encodeWAV};var h=o(746);Object.defineProperty(e,"AudioNodeVAD",{enumerable:!0,get:function(){return h.AudioNodeVAD}}),Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return h.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return h.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return h.getDefaultRealTimeVADOptions}})})(),r})()));

@@ -1,1 +0,1 @@

{"version":3,"file":"non-real-time-vad.d.ts","sourceRoot":"","sources":["../src/non-real-time-vad.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAgB,MAAM,UAAU,CAAA;AAG5E,UAAU,wBAAwB;IAChC,KAAK,EAAE,YAAY,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,qBACf,SAAQ,qBAAqB,EAC3B,UAAU;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,4BAA4B,EAAE,qBAK1C,CAAA;AAED,qBAAa,cAAc;IAkChB,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,qBAAqB;IAC9B,cAAc,EAAE,uBAAuB;WApCnC,GAAG,CAAC,OAAO,GAAE,OAAO,CAAC,qBAAqB,CAAM;gBAiCpD,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,qBAAqB,EAC9B,cAAc,EAAE,uBAAuB;IAGzC,GAAG,CACR,UAAU,EAAE,YAAY,EACxB,UAAU,EAAE,MAAM,GACjB,cAAc,CAAC,wBAAwB,CAAC;CAiD5C"}
{"version":3,"file":"non-real-time-vad.d.ts","sourceRoot":"","sources":["../src/non-real-time-vad.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAgB,MAAM,UAAU,CAAA;AAG5E,UAAU,wBAAwB;IAChC,KAAK,EAAE,YAAY,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,qBACf,SAAQ,qBAAqB,EAC3B,UAAU;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,4BAA4B,EAAE,qBAK1C,CAAA;AAED,qBAAa,cAAc;IAkChB,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,SAAS;IACd,OAAO,EAAE,qBAAqB;IAC9B,cAAc,EAAE,uBAAuB;WApCnC,GAAG,CAAC,OAAO,GAAE,OAAO,CAAC,qBAAqB,CAAM;gBAiCpD,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,qBAAqB,EAC9B,cAAc,EAAE,uBAAuB;IAGzC,GAAG,CACR,UAAU,EAAE,YAAY,EACxB,UAAU,EAAE,MAAM,GACjB,cAAc,CAAC,wBAAwB,CAAC;CAoD5C"}

@@ -81,4 +81,4 @@ "use strict";

let frameIndex = 0;
let messageContainer = [];
for await (const frame of resampler.stream(inputAudio)) {
const messageContainer = [];
await this.frameProcessor.process(frame, (event) => {

@@ -102,3 +102,4 @@ messageContainer.push(event);

}
const { msg, audio } = this.frameProcessor.endSegment((event) => {
const messageContainer = [];
this.frameProcessor.endSegment((event) => {
messageContainer.push(event);

@@ -105,0 +106,0 @@ });

@@ -1,1 +0,1 @@

{"version":3,"file":"non-real-time-vad.js","sourceRoot":"","sources":["../src/non-real-time-vad.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAE9C,6CAA4C;AAC5C,mEAA6D;AAC7D,uDAO0B;AAC1B,yCAAoC;AACpC,qCAA4E;AAC5E,2CAAuC;AAe1B,QAAA,4BAA4B,GAA0B;IACjE,GAAG,oDAAkC;IACrC,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,0BAAa,GAAG,wBAAwB;IAClD,YAAY,EAAE,2CAAmB;CAClC,CAAA;AAED,MAAa,cAAc;IACzB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAA0C,EAAE;QAC3D,MAAM,WAAW,GAAG;YAClB,GAAG,oCAA4B;YAC/B,GAAG,OAAO;SACX,CAAA;QACD,IAAA,iCAAe,EAAC,WAAW,CAAC,CAAA;QAE5B,IAAI,WAAW,CAAC,SAAS,KAAK,SAAS,EAAE;YACvC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;SACnC;QACD,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACzE,MAAM,KAAK,GAAG,MAAM,qBAAY,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;QAE/D,MAAM,cAAc,GAAG,IAAI,gCAAc,CACvC,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,WAAW,EACjB;YACE,YAAY,EAAE,WAAW,CAAC,YAAY;YACtC,uBAAuB,EAAE,WAAW,CAAC,uBAAuB;YAC5D,uBAAuB,EAAE,WAAW,CAAC,uBAAuB;YAC5D,g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,MAAK;oBAEP;wBACE,MAAK;iBACR;aACF;YACD,UAAU,EAAE,CAAA;SACb;QAED,MAAM,gBAAgB,GAA0B,EAAE,CAAA;QAClD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;YACvC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC,CAAC,CAAA;QAEF,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE;YACpC,QAAQ,KAAK,CAAC,GAAG,EAAE;gBACjB,KAAK,kBAAO,CAAC,SAAS;oBACpB,MAAM;wBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;wBAClB,KAAK;wBACL,GAAG,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE;qBACnD,CAAA;aACJ;SACF;IACH,CAAC;CACF;AA/FD,wCA+FC"}

@@ -23,7 +23,2 @@ import * as ortInstance from "onnxruntime-web";

}
/**
* Customizable audio constraints for the VAD.
* Excludes certain constraints that are set for the user by default.
*/
type AudioConstraints = Omit<MediaTrackConstraints, "channelCount" | "echoCancellation" | "autoGainControl" | "noiseSuppression">;
type AssetOptions = {

@@ -38,3 +33,3 @@ workletOptions: AudioWorkletNodeOptions;

interface RealTimeVADOptionsWithoutStream extends FrameProcessorOptions, RealTimeVADCallbacks, OrtOptions, AssetOptions, ModelOptions {
additionalAudioConstraints?: AudioConstraints;
additionalAudioConstraints?: MediaTrackConstraints;
stream: undefined;

@@ -41,0 +36,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"real-time-vad.d.ts","sourceRoot":"","sources":["../src/real-time-vad.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EAItB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAGL,UAAU,EAGV,mBAAmB,EACpB,MAAM,UAAU,CA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C,OAAO,GAAE,OAAO,CAAC,kBAAkB,CAAM;IAqC1D,OAAO;IASP,KAAK,aAMJ;IAED,MAAM,sBAkBL;IAED,KAAK,aAUJ;IAED,OAAO,aAUN;IAED,UAAU,yBAET;CACF;AAED,qBAAa,YAAY;IAwDd,GAAG,EAAE,YAAY;IACjB,OAAO,EAAE,kBAAkB;IAxDpC,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,MAAM,CAAC,CAAc;IAC7B,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAW;WAEhB,GAAG,CACd,GAAG,EAAE,YAAY,EACjB,OAAO,GAAE,OAAO,CAAC,kBAAkB,CAAM;gBA8ClC,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,kBAAkB,EAClC,cAAc,EAAE,cAAc;YAKlB,cAAc;IA2F5B,KAAK,aAEJ;IAED,KAAK,aAEJ;IAED,OAAO,SAAU,SAAS,UAEzB;IAED,YAAY,UAAiB,YAAY,mBAExC;IAED,yBAAyB,OAAQ,mBAAmB,UAsBnD;IAED,OAAO,aAQN;IAED,wBAAwB,yBAKvB;CACF"}

@@ -78,3 +78,2 @@ "use strict";

audio: {
...fullOptions.additionalAudioConstraints,
channelCount: 1,

@@ -84,2 +83,3 @@ echoCancellation: true,

noiseSuppression: true,
...fullOptions.additionalAudioConstraints,
},

@@ -117,3 +117,2 @@ });

audio: {
...additionalAudioConstraints,
channelCount: 1,

@@ -123,2 +122,3 @@ echoCancellation: true,

noiseSuppression: true,
...additionalAudioConstraints,
},

@@ -125,0 +125,0 @@ });

@@ -1,1 +0,1 @@

{"version":3,"file":"real-time-vad.js","sourceRoot":"","sources":["../src/real-time-vad.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,mEAA6D;AAC7D,uDAO0B;AAC1B,uC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