jssz-meeting-component 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -37712,323 +37712,6 @@ function markNetworkDisconnected() {
37712
37712
  );
37713
37713
  handleLevelNotification("lost");
37714
37714
  }
37715
- class AssetLoader {
37716
- constructor(config = {}) {
37717
- this.cdnUrl = config.cdnUrl ?? "https://cdn.mezon.ai/AI/models/datas/noise_suppression/deepfilternet3";
37718
- }
37719
- getCdnUrl(relativePath) {
37720
- return `${this.cdnUrl}/${relativePath}`;
37721
- }
37722
- getAssetUrls() {
37723
- return {
37724
- wasm: this.getCdnUrl("v2/pkg/df_bg.wasm"),
37725
- model: this.getCdnUrl("v2/models/DeepFilterNet3_onnx.tar.gz")
37726
- };
37727
- }
37728
- async fetchAsset(url) {
37729
- const response = await fetch(url);
37730
- if (!response.ok) {
37731
- throw new Error(`Failed to fetch asset: ${response.statusText}`);
37732
- }
37733
- return response.arrayBuffer();
37734
- }
37735
- }
37736
- let defaultLoader = null;
37737
- function getAssetLoader(config) {
37738
- if (!defaultLoader || config) {
37739
- defaultLoader = new AssetLoader(config);
37740
- }
37741
- return defaultLoader;
37742
- }
37743
- async function createWorkletModule(audioContext, workletCode2) {
37744
- const blob = new Blob([workletCode2], { type: "application/javascript" });
37745
- const blobUrl = URL.createObjectURL(blob);
37746
- await audioContext.audioWorklet.addModule(blobUrl);
37747
- }
37748
- const WorkletMessageTypes = {
37749
- SET_SUPPRESSION_LEVEL: "SET_SUPPRESSION_LEVEL",
37750
- SET_BYPASS: "SET_BYPASS"
37751
- };
37752
- var workletCode = "(function () {\n 'use strict';\n\n let wasm;\n\n const heap = new Array(128).fill(undefined);\n\n heap.push(undefined, null, true, false);\n\n function getObject(idx) { return heap[idx]; }\n\n let heap_next = heap.length;\n\n function dropObject(idx) {\n if (idx < 132) return;\n heap[idx] = heap_next;\n heap_next = idx;\n }\n\n function takeObject(idx) {\n const ret = getObject(idx);\n dropObject(idx);\n return ret;\n }\n\n const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\n if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }\n let cachedUint8Memory0 = null;\n\n function getUint8Memory0() {\n if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {\n cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8Memory0;\n }\n\n function getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));\n }\n\n function addHeapObject(obj) {\n if (heap_next === heap.length) heap.push(heap.length + 1);\n const idx = heap_next;\n heap_next = heap[idx];\n\n heap[idx] = obj;\n return idx;\n }\n /**\n * Set DeepFilterNet attenuation limit.\n *\n * Args:\n * - lim_db: New attenuation limit in dB.\n * @param {number} st\n * @param {number} lim_db\n */\n function df_set_atten_lim(st, lim_db) {\n wasm.df_set_atten_lim(st, lim_db);\n }\n\n /**\n * Get DeepFilterNet frame size in samples.\n * @param {number} st\n * @returns {number}\n */\n function df_get_frame_length(st) {\n const ret = wasm.df_get_frame_length(st);\n return ret >>> 0;\n }\n\n let WASM_VECTOR_LEN = 0;\n\n function passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8Memory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n }\n /**\n * Create a DeepFilterNet Model\n *\n * Args:\n * - path: File path to a DeepFilterNet tar.gz onnx model\n * - atten_lim: Attenuation limit in dB.\n *\n * Returns:\n * - DF state doing the full processing: stft, DNN noise reduction, istft.\n * @param {Uint8Array} model_bytes\n * @param {number} atten_lim\n * @returns {number}\n */\n function df_create(model_bytes, atten_lim) {\n const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.df_create(ptr0, len0, atten_lim);\n return ret >>> 0;\n }\n\n let cachedFloat32Memory0 = null;\n\n function getFloat32Memory0() {\n if (cachedFloat32Memory0 === null || cachedFloat32Memory0.byteLength === 0) {\n cachedFloat32Memory0 = new Float32Array(wasm.memory.buffer);\n }\n return cachedFloat32Memory0;\n }\n\n function passArrayF32ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 4, 4) >>> 0;\n getFloat32Memory0().set(arg, ptr / 4);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n }\n /**\n * Processes a chunk of samples.\n *\n * Args:\n * - df_state: Created via df_create()\n * - input: Input buffer of length df_get_frame_length()\n * - output: Output buffer of length df_get_frame_length()\n *\n * Returns:\n * - Local SNR of the current frame.\n * @param {number} st\n * @param {Float32Array} input\n * @returns {Float32Array}\n */\n function df_process_frame(st, input) {\n const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.df_process_frame(st, ptr0, len0);\n return takeObject(ret);\n }\n\n function handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n wasm.__wbindgen_exn_store(addHeapObject(e));\n }\n }\n\n (typeof FinalizationRegistry === 'undefined')\n ? { }\n : new FinalizationRegistry(ptr => wasm.__wbg_dfstate_free(ptr >>> 0));\n\n function __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n imports.wbg.__wbindgen_object_drop_ref = function(arg0) {\n takeObject(arg0);\n };\n imports.wbg.__wbg_crypto_566d7465cdbb6b7a = function(arg0) {\n const ret = getObject(arg0).crypto;\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_is_object = function(arg0) {\n const val = getObject(arg0);\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n };\n imports.wbg.__wbg_process_dc09a8c7d59982f6 = function(arg0) {\n const ret = getObject(arg0).process;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_versions_d98c6400c6ca2bd8 = function(arg0) {\n const ret = getObject(arg0).versions;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_node_caaf83d002149bd5 = function(arg0) {\n const ret = getObject(arg0).node;\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_is_string = function(arg0) {\n const ret = typeof(getObject(arg0)) === 'string';\n return ret;\n };\n imports.wbg.__wbg_require_94a9da52636aacbf = function() { return handleError(function () {\n const ret = module.require;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbindgen_is_function = function(arg0) {\n const ret = typeof(getObject(arg0)) === 'function';\n return ret;\n };\n imports.wbg.__wbindgen_string_new = function(arg0, arg1) {\n const ret = getStringFromWasm0(arg0, arg1);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_msCrypto_0b84745e9245cdf6 = function(arg0) {\n const ret = getObject(arg0).msCrypto;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_randomFillSync_290977693942bf03 = function() { return handleError(function (arg0, arg1) {\n getObject(arg0).randomFillSync(takeObject(arg1));\n }, arguments) };\n imports.wbg.__wbg_getRandomValues_260cc23a41afad9a = function() { return handleError(function (arg0, arg1) {\n getObject(arg0).getRandomValues(getObject(arg1));\n }, arguments) };\n imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {\n const ret = new Uint8Array(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_new_9efabd6b6d2ce46d = function(arg0) {\n const ret = new Float32Array(getObject(arg0));\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {\n const ret = getObject(arg0).buffer;\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {\n const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {\n getObject(arg0).set(getObject(arg1), arg2 >>> 0);\n };\n imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {\n const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_newwithbyteoffsetandlength_4a659d079a1650e0 = function(arg0, arg1, arg2) {\n const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {\n const ret = self.self;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {\n const ret = window.window;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {\n const ret = globalThis.globalThis;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () {\n const ret = global.global;\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbindgen_is_undefined = function(arg0) {\n const ret = getObject(arg0) === undefined;\n return ret;\n };\n imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {\n const ret = getObject(arg0).call(getObject(arg1));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbindgen_object_clone_ref = function(arg0) {\n const ret = getObject(arg0);\n return addHeapObject(ret);\n };\n imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {\n const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));\n return addHeapObject(ret);\n }, arguments) };\n imports.wbg.__wbindgen_memory = function() {\n const ret = wasm.memory;\n return addHeapObject(ret);\n };\n imports.wbg.__wbindgen_throw = function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n };\n\n return imports;\n }\n\n function __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n cachedFloat32Memory0 = null;\n cachedUint8Memory0 = null;\n\n\n return wasm;\n }\n\n function initSync(module) {\n if (wasm !== undefined) return wasm;\n\n const imports = __wbg_get_imports();\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance);\n }\n\n const WorkletMessageTypes = {\n SET_SUPPRESSION_LEVEL: 'SET_SUPPRESSION_LEVEL',\n SET_BYPASS: 'SET_BYPASS'\n };\n\n class DeepFilterAudioProcessor extends AudioWorkletProcessor {\n constructor(options) {\n super();\n this.dfModel = null;\n this.inputWritePos = 0;\n this.inputReadPos = 0;\n this.outputWritePos = 0;\n this.outputReadPos = 0;\n this.bypass = false;\n this.isInitialized = false;\n this.tempFrame = null;\n this.bufferSize = 8192;\n this.inputBuffer = new Float32Array(this.bufferSize);\n this.outputBuffer = new Float32Array(this.bufferSize);\n try {\n // Initialize WASM from pre-compiled module\n initSync(options.processorOptions.wasmModule);\n const modelBytes = new Uint8Array(options.processorOptions.modelBytes);\n const handle = df_create(modelBytes, options.processorOptions.suppressionLevel ?? 50);\n const frameLength = df_get_frame_length(handle);\n this.dfModel = { handle, frameLength };\n this.bufferSize = frameLength * 4;\n this.inputBuffer = new Float32Array(this.bufferSize);\n this.outputBuffer = new Float32Array(this.bufferSize);\n // Pre-allocate temp frame buffer for processing\n this.tempFrame = new Float32Array(frameLength);\n this.isInitialized = true;\n this.port.onmessage = (event) => {\n this.handleMessage(event.data);\n };\n }\n catch (error) {\n console.error('Failed to initialize DeepFilter in AudioWorklet:', error);\n this.isInitialized = false;\n }\n }\n handleMessage(data) {\n switch (data.type) {\n case WorkletMessageTypes.SET_SUPPRESSION_LEVEL:\n if (this.dfModel && typeof data.value === 'number') {\n const level = Math.max(0, Math.min(100, Math.floor(data.value)));\n df_set_atten_lim(this.dfModel.handle, level);\n }\n break;\n case WorkletMessageTypes.SET_BYPASS:\n this.bypass = Boolean(data.value);\n break;\n }\n }\n getInputAvailable() {\n return (this.inputWritePos - this.inputReadPos + this.bufferSize) % this.bufferSize;\n }\n getOutputAvailable() {\n return (this.outputWritePos - this.outputReadPos + this.bufferSize) % this.bufferSize;\n }\n process(inputList, outputList) {\n const sourceLimit = Math.min(inputList.length, outputList.length);\n const input = inputList[0]?.[0];\n if (!input) {\n return true;\n }\n // Passthrough mode - copy input to all output channels\n if (!this.isInitialized || !this.dfModel || this.bypass || !this.tempFrame) {\n for (let inputNum = 0; inputNum < sourceLimit; inputNum++) {\n const output = outputList[inputNum];\n const channelCount = output.length;\n for (let channelNum = 0; channelNum < channelCount; channelNum++) {\n output[channelNum].set(input);\n }\n }\n return true;\n }\n // Write input to ring buffer\n for (let i = 0; i < input.length; i++) {\n this.inputBuffer[this.inputWritePos] = input[i];\n this.inputWritePos = (this.inputWritePos + 1) % this.bufferSize;\n }\n const frameLength = this.dfModel.frameLength;\n while (this.getInputAvailable() >= frameLength) {\n // Extract frame from ring buffer\n for (let i = 0; i < frameLength; i++) {\n this.tempFrame[i] = this.inputBuffer[this.inputReadPos];\n this.inputReadPos = (this.inputReadPos + 1) % this.bufferSize;\n }\n const processed = df_process_frame(this.dfModel.handle, this.tempFrame);\n // Write to output ring buffer\n for (let i = 0; i < processed.length; i++) {\n this.outputBuffer[this.outputWritePos] = processed[i];\n this.outputWritePos = (this.outputWritePos + 1) % this.bufferSize;\n }\n }\n const outputAvailable = this.getOutputAvailable();\n if (outputAvailable >= 128) {\n for (let inputNum = 0; inputNum < sourceLimit; inputNum++) {\n const output = outputList[inputNum];\n const channelCount = output.length;\n for (let channelNum = 0; channelNum < channelCount; channelNum++) {\n const outputChannel = output[channelNum];\n let readPos = this.outputReadPos;\n for (let i = 0; i < 128; i++) {\n outputChannel[i] = this.outputBuffer[readPos];\n readPos = (readPos + 1) % this.bufferSize;\n }\n }\n }\n this.outputReadPos = (this.outputReadPos + 128) % this.bufferSize;\n }\n return true;\n }\n }\n registerProcessor('deepfilter-audio-processor', DeepFilterAudioProcessor);\n\n})();\n";
37753
- class DeepFilterNet3Core {
37754
- constructor(config = {}) {
37755
- this.assets = null;
37756
- this.workletNode = null;
37757
- this.isInitialized = false;
37758
- this.bypassEnabled = false;
37759
- this.config = {
37760
- sampleRate: config.sampleRate ?? 48e3,
37761
- noiseReductionLevel: config.noiseReductionLevel ?? 50,
37762
- assetConfig: config.assetConfig
37763
- };
37764
- this.assetLoader = getAssetLoader(config.assetConfig);
37765
- }
37766
- async initialize() {
37767
- if (this.isInitialized)
37768
- return;
37769
- const assetUrls = this.assetLoader.getAssetUrls();
37770
- const [wasmBytes, modelBytes] = await Promise.all([
37771
- this.assetLoader.fetchAsset(assetUrls.wasm),
37772
- this.assetLoader.fetchAsset(assetUrls.model)
37773
- ]);
37774
- const wasmModule = await WebAssembly.compile(wasmBytes);
37775
- this.assets = { wasmModule, modelBytes };
37776
- this.isInitialized = true;
37777
- }
37778
- async createAudioWorkletNode(audioContext) {
37779
- this.ensureInitialized();
37780
- if (!this.assets) {
37781
- throw new Error("Assets not loaded");
37782
- }
37783
- await createWorkletModule(audioContext, workletCode);
37784
- this.workletNode = new AudioWorkletNode(audioContext, "deepfilter-audio-processor", {
37785
- processorOptions: {
37786
- wasmModule: this.assets.wasmModule,
37787
- modelBytes: this.assets.modelBytes,
37788
- suppressionLevel: this.config.noiseReductionLevel
37789
- }
37790
- });
37791
- return this.workletNode;
37792
- }
37793
- setSuppressionLevel(level) {
37794
- if (!this.workletNode || typeof level !== "number" || isNaN(level))
37795
- return;
37796
- const clampedLevel = Math.max(0, Math.min(100, Math.floor(level)));
37797
- this.workletNode.port.postMessage({
37798
- type: WorkletMessageTypes.SET_SUPPRESSION_LEVEL,
37799
- value: clampedLevel
37800
- });
37801
- }
37802
- destroy() {
37803
- if (!this.isInitialized)
37804
- return;
37805
- if (this.workletNode) {
37806
- this.workletNode.disconnect();
37807
- this.workletNode = null;
37808
- }
37809
- this.assets = null;
37810
- this.isInitialized = false;
37811
- }
37812
- isReady() {
37813
- return this.isInitialized && this.workletNode !== null;
37814
- }
37815
- setNoiseSuppressionEnabled(enabled) {
37816
- if (!this.workletNode)
37817
- return;
37818
- this.bypassEnabled = !enabled;
37819
- this.workletNode.port.postMessage({
37820
- type: WorkletMessageTypes.SET_BYPASS,
37821
- value: !enabled
37822
- });
37823
- }
37824
- isNoiseSuppressionEnabled() {
37825
- return !this.bypassEnabled;
37826
- }
37827
- ensureInitialized() {
37828
- if (!this.isInitialized) {
37829
- throw new Error("Processor not initialized. Call initialize() first.");
37830
- }
37831
- }
37832
- }
37833
- const GZIP_FIX_FLAG = "__srtcGzipFix";
37834
- function patchAssetLoaderGzipFix() {
37835
- const proto = AssetLoader.prototype;
37836
- if (proto[GZIP_FIX_FLAG]) {
37837
- return;
37838
- }
37839
- const original = proto.fetchAsset;
37840
- proto.fetchAsset = async function(url) {
37841
- const buf = await original.call(this, url);
37842
- if (!url.endsWith(".tar.gz")) {
37843
- return buf;
37844
- }
37845
- const head = new Uint8Array(buf);
37846
- if (head[0] === 31 && head[1] === 139) {
37847
- return buf;
37848
- }
37849
- const isTar = head.length > 262 && head[257] === 117 && head[258] === 115 && head[259] === 116 && head[260] === 97 && head[261] === 114;
37850
- if (isTar) {
37851
- if (typeof CompressionStream === "undefined") {
37852
- throw new Error("DeepFilterNet 模型被服务器以 Content-Encoding 解压,且当前环境不支持 CompressionStream 无法自动还原;请让服务器对 .tar.gz 不要设置 Content-Encoding: gzip。");
37853
- }
37854
- const stream = new Response(buf).body.pipeThrough(new CompressionStream("gzip"));
37855
- return await new Response(stream).arrayBuffer();
37856
- }
37857
- throw new Error(`DeepFilterNet 模型内容无效(既非 gzip 也非 tar,可能路径错误或命中 SPA fallback):${url}`);
37858
- };
37859
- proto[GZIP_FIX_FLAG] = true;
37860
- }
37861
- class DeepFilterNetProcessor {
37862
- constructor(options = {}) {
37863
- this.name = "deepfilternet";
37864
- this.ownContext = false;
37865
- this.suppressionLevel = options.suppressionLevel ?? 50;
37866
- this.assetBasePath = options.assetBasePath ?? "/";
37867
- this.cdnUrl = options.cdnUrl;
37868
- }
37869
- resolveAssetBase() {
37870
- return (this.cdnUrl ?? this.assetBasePath).replace(/\/+$/, "");
37871
- }
37872
- async init(options) {
37873
- if (options.kind !== Bn.Audio) {
37874
- throw new Error("DeepFilterNetProcessor 仅支持音频轨道");
37875
- }
37876
- if (options.audioContext) {
37877
- this.audioContext = options.audioContext;
37878
- this.ownContext = false;
37879
- } else {
37880
- this.audioContext = new (window.AudioContext || window.webkitAudioContext)({
37881
- sampleRate: 48e3,
37882
- latencyHint: "interactive"
37883
- });
37884
- this.ownContext = true;
37885
- }
37886
- patchAssetLoaderGzipFix();
37887
- this.core = new DeepFilterNet3Core({
37888
- sampleRate: 48e3,
37889
- noiseReductionLevel: this.suppressionLevel,
37890
- assetConfig: { cdnUrl: this.resolveAssetBase() }
37891
- });
37892
- await this.core.initialize();
37893
- this.workletNode = await this.core.createAudioWorkletNode(this.audioContext);
37894
- this.sourceNode = this.audioContext.createMediaStreamSource(new MediaStream([options.track]));
37895
- this.destinationNode = this.audioContext.createMediaStreamDestination();
37896
- this.sourceNode.connect(this.workletNode);
37897
- this.workletNode.connect(this.destinationNode);
37898
- const tracks = this.destinationNode.stream.getAudioTracks();
37899
- if (!tracks.length) {
37900
- throw new Error("DeepFilterNetProcessor 未产出音频轨道");
37901
- }
37902
- this.processedTrack = tracks[0];
37903
- }
37904
- setSuppressionLevel(level) {
37905
- var _a25;
37906
- this.suppressionLevel = Math.max(0, Math.min(100, Math.floor(level)));
37907
- (_a25 = this.core) == null ? void 0 : _a25.setSuppressionLevel(this.suppressionLevel);
37908
- }
37909
- setEnabled(enabled) {
37910
- var _a25;
37911
- (_a25 = this.core) == null ? void 0 : _a25.setNoiseSuppressionEnabled(enabled);
37912
- }
37913
- async destroy() {
37914
- var _a25, _b25, _c2;
37915
- (_a25 = this.core) == null ? void 0 : _a25.destroy();
37916
- (_b25 = this.sourceNode) == null ? void 0 : _b25.disconnect();
37917
- (_c2 = this.destinationNode) == null ? void 0 : _c2.disconnect();
37918
- if (this.ownContext && this.audioContext && this.audioContext.state !== "closed") {
37919
- await this.audioContext.close();
37920
- }
37921
- this.core = void 0;
37922
- this.sourceNode = void 0;
37923
- this.workletNode = void 0;
37924
- this.destinationNode = void 0;
37925
- this.audioContext = void 0;
37926
- this.processedTrack = void 0;
37927
- }
37928
- }
37929
- const MIC_NOISE_REDUCTION_PREFS_KEY = "JS_MIC_NOISE_REDUCTION_PREFS";
37930
- const DEFAULT_SUPPRESSION_LEVEL = 50;
37931
- const DEFAULT_ASSET_BASE_PATH = "/deepfilternet/";
37932
- function clampSuppressionLevel(level) {
37933
- if (!Number.isFinite(level)) return DEFAULT_SUPPRESSION_LEVEL;
37934
- return Math.max(0, Math.min(100, Math.round(level)));
37935
- }
37936
- function readPrefs() {
37937
- try {
37938
- const raw = localStorage.getItem(MIC_NOISE_REDUCTION_PREFS_KEY);
37939
- if (!raw) return {};
37940
- const parsed = JSON.parse(raw);
37941
- return parsed && typeof parsed === "object" ? parsed : {};
37942
- } catch {
37943
- return {};
37944
- }
37945
- }
37946
- const initialPrefs$1 = readPrefs();
37947
- const micNoiseReductionState = reactive({
37948
- enabled: initialPrefs$1.enabled ?? true,
37949
- suppressionLevel: clampSuppressionLevel(
37950
- initialPrefs$1.suppressionLevel ?? DEFAULT_SUPPRESSION_LEVEL
37951
- ),
37952
- assetBasePath: typeof initialPrefs$1.assetBasePath === "string" && initialPrefs$1.assetBasePath.trim() ? initialPrefs$1.assetBasePath : DEFAULT_ASSET_BASE_PATH
37953
- });
37954
- const micNoiseReductionError = ref("");
37955
- let currentTrack;
37956
- let currentProcessor;
37957
- let operationQueue = Promise.resolve();
37958
- function enqueueOperation(operation) {
37959
- const next = operationQueue.then(operation, operation);
37960
- operationQueue = next.then(
37961
- () => void 0,
37962
- () => void 0
37963
- );
37964
- return next;
37965
- }
37966
- async function destroyProcessor(track) {
37967
- if (!currentProcessor) return;
37968
- if (track) {
37969
- try {
37970
- await track.removeProcessor();
37971
- } catch (_2) {
37972
- }
37973
- }
37974
- try {
37975
- await currentProcessor.destroy();
37976
- } catch (_2) {
37977
- }
37978
- currentProcessor = void 0;
37979
- }
37980
- async function applyToTrack(track = currentTrack) {
37981
- if (!track) {
37982
- await destroyProcessor();
37983
- micNoiseReductionError.value = "";
37984
- return { status: "disabled" };
37985
- }
37986
- if (!micNoiseReductionState.enabled) {
37987
- if (currentProcessor) {
37988
- currentProcessor.setSuppressionLevel(micNoiseReductionState.suppressionLevel);
37989
- currentProcessor.setEnabled(false);
37990
- }
37991
- micNoiseReductionError.value = "";
37992
- return { status: "disabled" };
37993
- }
37994
- try {
37995
- if (!currentProcessor) {
37996
- currentProcessor = new DeepFilterNetProcessor({
37997
- assetBasePath: micNoiseReductionState.assetBasePath,
37998
- suppressionLevel: micNoiseReductionState.suppressionLevel
37999
- });
38000
- await track.setProcessor(currentProcessor);
38001
- }
38002
- currentProcessor.setSuppressionLevel(micNoiseReductionState.suppressionLevel);
38003
- currentProcessor.setEnabled(true);
38004
- micNoiseReductionError.value = "";
38005
- return { status: "enabled" };
38006
- } catch (error) {
38007
- micNoiseReductionError.value = error instanceof Error ? error.message : "AI 降噪启用失败";
38008
- await destroyProcessor(track);
38009
- return { status: "failed", error };
38010
- }
38011
- }
38012
- function bindMicNoiseReductionTrack(track) {
38013
- return enqueueOperation(async () => {
38014
- const previousTrack = currentTrack;
38015
- currentTrack = track;
38016
- if (previousTrack && previousTrack !== track) {
38017
- await destroyProcessor(previousTrack);
38018
- }
38019
- return applyToTrack(track);
38020
- });
38021
- }
38022
- function releaseMicNoiseReductionTrack(track) {
38023
- return enqueueOperation(async () => {
38024
- const targetTrack = track || currentTrack;
38025
- if (currentTrack === targetTrack) {
38026
- currentTrack = void 0;
38027
- }
38028
- await destroyProcessor(targetTrack);
38029
- micNoiseReductionError.value = "";
38030
- });
38031
- }
38032
37715
  const alertMsg = "需要浏览器授权麦克风摄像头访问,才能进行音视频通话。请依次点击右上角三个点 > 设置 > 隐私设置和安全性 > 网站设置 > 摄像头或麦克风,把权限更改为 允许 。";
38033
37716
  const deviceInfo = reactive({
38034
37717
  speakers: [],
@@ -38509,7 +38192,6 @@ async function stopAndUnpublishLocalMicTrack() {
38509
38192
  await srtc.unpublishLocalTrack(track);
38510
38193
  } catch (_2) {
38511
38194
  }
38512
- await releaseMicNoiseReductionTrack(track);
38513
38195
  try {
38514
38196
  await track.stopCapture();
38515
38197
  } catch (_2) {
@@ -39299,18 +38981,16 @@ function openMic() {
39299
38981
  noiseSuppression: true,
39300
38982
  autoGainControl: true
39301
38983
  });
39302
- const noiseReductionResult = await bindMicNoiseReductionTrack(track);
39303
38984
  await srtc.publishLocalTrack(track, {
39304
38985
  priority: "high"
39305
38986
  });
39306
38987
  speechDetector.start(track);
39307
- if (noiseReductionResult.status === "failed") {
39308
- showNotification("AI 降噪启用失败,已自动回退为原始麦克风", "warning", 4e3);
39309
- }
38988
+ console.log("----------------123");
39310
38989
  meState.microPhoneState = "1";
39311
38990
  meetingStore$1.upsertMember(getUserId(), { audioStatus: "1" });
39312
38991
  writeSelfMediaPrefs({ audioStatus: "1" });
39313
38992
  } catch (error) {
38993
+ console.log("打开麦克风失败", error);
39314
38994
  showNotification("打开麦克风失败", "error", 3e3);
39315
38995
  try {
39316
38996
  await handleControl({