69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
|
|
/**
|
||
|
|
* Detection utilities for Lotus ML noise suppression (RNNoise).
|
||
|
|
*/
|
||
|
|
|
||
|
|
export type DenoiseModel = {
|
||
|
|
id: string;
|
||
|
|
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 (Mozilla)',
|
||
|
|
description: 'Lightweight hybrid model. Best for consistent noise like fans.',
|
||
|
|
cpuUsage: '< 5%',
|
||
|
|
binarySize: '< 1 MB',
|
||
|
|
transients: 'Poor',
|
||
|
|
voiceQuality: 'Moderate',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: 'dtln',
|
||
|
|
name: 'DTLN (Balanced)',
|
||
|
|
description: 'Deep learning model with a good balance of quality and CPU.',
|
||
|
|
cpuUsage: '10-20%',
|
||
|
|
binarySize: '3-4 MB',
|
||
|
|
transients: 'Good',
|
||
|
|
voiceQuality: 'High',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
id: 'deepfilternet',
|
||
|
|
name: 'DeepFilterNet 3 (Pro)',
|
||
|
|
description: 'State-of-the-art studio quality. Removes all background noise.',
|
||
|
|
cpuUsage: '25-50%+',
|
||
|
|
binarySize: '15-20 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',
|
||
|
|
];
|
||
|
|
|