Files
cinny/src/app/utils/lotusDenoiseUtils.ts
T

79 lines
2.2 KiB
TypeScript
Raw Normal View History

/**
* Detection utilities for Lotus ML noise suppression (RNNoise).
*/
2026-06-17 20:02:16 -04:00
import { DenoiseModelId } from '../state/settings';
export type DenoiseModel = {
2026-06-17 20:02:16 -04:00
id: DenoiseModelId;
name: string;
description: string;
cpuUsage: string;
binarySize: string;
transients: 'Poor' | 'Good' | 'Excellent';
voiceQuality: 'Moderate' | 'High' | 'Very High';
};
export const DENOISE_MODELS: DenoiseModel[] = [
{
id: 'rnnoise',
name: 'RNNoise',
description: 'Lightweight hybrid model. Best for consistent noise like fans.',
cpuUsage: '< 5%',
binarySize: '< 1 MB',
transients: 'Good',
voiceQuality: 'High',
},
{
id: 'speex',
name: 'Speex (Legacy)',
description: 'Classic DSP noise suppressor. Minimal CPU, gentler on voice.',
cpuUsage: '< 2%',
binarySize: '< 1 MB',
transients: 'Poor',
voiceQuality: 'Moderate',
},
{
id: 'dtln',
name: 'DTLN (beta)',
description: 'Deep-learning model (TFLite). Stronger on transient noise; higher CPU.',
cpuUsage: '10-20%',
binarySize: '~4 MB',
transients: 'Excellent',
voiceQuality: 'High',
},
{
id: 'deepfilternet',
name: 'DeepFilterNet 3 (beta)',
description: 'Studio-grade deep-learning model (48 kHz, ONNX). Best quality; highest CPU.',
cpuUsage: '25-50%',
binarySize: '~18 MB',
transients: 'Excellent',
voiceQuality: 'Very High',
},
];
export const isMLDenoiseSupported = (): boolean => {
if (typeof window === 'undefined') return false;
// Requirements:
// 1. AudioContext/webkitAudioContext (Web Audio API)
// 2. AudioWorklet (Real-time processing in a background thread)
// 3. getUserMedia (Microphone access)
const hasAudioContext = !!(window.AudioContext || (window as any).webkitAudioContext);
const hasAudioWorklet = hasAudioContext && !!AudioWorkletNode;
const hasGetUserMedia = !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia);
return hasAudioWorklet && hasGetUserMedia;
};
/**
* EXACT requirements for ML Denoise (for UI display).
*/
export const ML_DENOISE_REQUIREMENTS = [
'Modern browser with Web Audio API support',
'AudioWorklet support (Chrome 66+, Firefox 76+, Safari 14.1+)',
'Microphone access',
'48kHz AudioContext capability',
];