Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • atsvb

Index

Constructors

  • new atsvb(customer_id?: string): atsvb
  • Initiation of main SDK instance.

    Parameters

    • Optional customer_id: string

      the unique customer identifier provided by SDK vendor.

    Returns atsvb

Properties

onReady?: (() => void)

Type declaration

    • (): void
    • Returns void

Methods

  • clear(): void
  • This call will destroy the audio graph and worker along with all resources.

    Returns void

  • clearCache(): Promise<void>
  • Ability to clear all models from local cache

    Returns Promise<void>

  • config(config: any): void
  • Ability to configure sdk execution environment

    example

    General configuration options

    config = {
    customer_id: 'customer_id', // Specify customer_id (can also be specified by passing it to the SDK constructor)
    api_url: 'url', // Custom URL for SDK authentication, applicable for on-premises
    sdk_url: 'url', // Specifies the URL to the SDK folder in case you host model files yourself
    preset: 'balanced', / You can specify the default segmentation preset (quality, speed, balanced)
    sample_rate: 48000, // You can specify the default sample rate for model processing
    context_sample_rate: 48000, // Sample rate of the internal AudioContext. 0 (default) lets the browser choose. Set it to match the encoder (e.g. 48000 for Opus) to avoid an extra resampling step on the output track. Must be set before the input stream is attached.
    cacheModels: true, // If true, the SDK will load ML models locally, making subsequent loads faster with no network requests
    processingChunk: 64, // Frame size for communication between worklet and worker in milliseconds; higher value -> more latency and less CPU usage, and vice versa
    latency_mode: 'auto', // Latency policy: 'auto', 'low', or 'stable'. Auto starts low and backs off after underruns.
    denoise_stages: { enabled: true, noiseOnlyLsnrDb: -10, skipDfLsnrDb: 20, bypassLsnrDb: 30 }, // LSNR-based stage skipping for the wasm presets; see setDenoiseStages()
    processorType: 'worklet', // Specify the processor type: 'worklet' for real-time streaming or 'buffer' for file processing
    wasmPaths: { // Currently, WASM files are loaded from the same directory where the SDK is placed, but custom URLs are also supported (e.g., loading from CDNs)
    'ort-wasm.wasm': 'url',
    'ort-wasm-simd.wasm': 'url',
    }
    }
    example

    Example of how to change default denoise quality preset

    config = {
    preset: 'quality'
    sample_rate: 48000
    }
    example

    Example of how to configure processor type for file processing

    config = {
    processorType: 'buffer' // Use buffer processor for file processing instead of real-time streaming
    }
    example

    Example of how to hot models on custom domain

    config = {
    sdk_url: 'https://domain.com/sdk/' // in this derectory should be subfolder models with all required models
    }

    Parameters

    • config: any

      configuration object

    Returns void

  • dbg(value: any): void
  • Parameters

    • value: any

    Returns void

  • disableStudioSound(): void
  • Returns void

  • enableDebugStats(enabled: boolean): void
  • Parameters

    • enabled: boolean

    Returns void

  • enableStudioSound(): void
  • Returns void

  • getAudioTrack(): MediaStreamAudioTrack
  • Get the output MediaStreamTrack object with denoise applied for further use.

    Returns MediaStreamAudioTrack

  • getCustomerId(): string
  • Get Customer ID provided by vendor.

    Returns string

  • Get the currently configured LSNR stage-skipping options. Returns null when stage skipping was never configured (full denoising).

    Returns null | DenoiseStagesOptions

  • getInputAudioTrack(): null | MediaStreamAudioTrack
  • Get the input MediaStreamTrack the SDK is currently reading from.

    Useful for checking what the browser actually applied to the capture — getSettings() on it reports whether browser-side AGC, noise suppression or echo cancellation ended up enabled, which changes what the SDK receives.

    Returns null | MediaStreamAudioTrack

  • getLatencyMs(): number
  • Returns the current output buffer latency in milliseconds. Updated every ~100ms. Returns 0 if the processor is not yet initialized.

    Returns number

  • getRequiredModels(): { path: string; preset: ModelType; url: string }[]
  • The model files this SDK version needs, and where it will look for them.

    Model file names are tied to the SDK version and change between releases — speed has already moved from a .tsvb to a .wasm build, not just to a new version number. If you host the models yourself, an SDK update can therefore start asking for a file your folder does not have, and the only symptom is that initialization never completes. Use this to check the folder after upgrading, or at startup before the first call.

    Call it after config(): url is resolved against the configured sdk_url, so it only means something once that is set.

    example
    sdk.config({ sdk_url: 'https://cdn.example.com/audio/' });
    for (const m of sdk.getRequiredModels()) {
    const res = await fetch(m.url, { method: 'HEAD' });
    if (!res.ok) console.error(`missing model for "${m.preset}": ${m.path}`);
    }

    Returns { path: string; preset: ModelType; url: string }[]

    one entry per preset: the preset name, the path relative to sdk_url, and the absolute URL that will be fetched.

  • getSpeedupDebugInfo(): any
  • Returns a snapshot of the adaptive speedup/jitter-buffer state for debugging. Updated every ~100ms. Returns null if the processor is not yet initialized.

    Fields:

    • latencyMs — total pipeline latency (input + worker + output buffers)
    • outputBufferMs — frames currently in the output ring buffer
    • floorMs — learned safe output-buffer floor
    • minFloorMs — physical minimum floor derived from processing chunk size
    • latencyMode — configured latency policy: auto, low, or stable
    • latencyProfile — currently active internal profile
    • minInWindowMs — observed minimum in current 3s window (null if no data yet)
    • isSpeedingUp — whether OLA speedup is currently active
    • hadUnderrunInWindow— whether an underrun occurred in the current window
    • consecutiveStableWindows — windows that stayed safely above floor
    • contextSampleRate — actual AudioContext rate (see the contextSampleRate config)
    • modelSampleRate — rate the model runs at; differs from the context rate → resampling is active

    Returns any

  • getStream(): MediaStream
  • This object remains permanent throughout the entire lifetime of the SDK instance. When a new stream is provided as the source for processing, the SDK replaces the audio track within this MediaStream.

    Returns MediaStream

  • isRunning(): boolean
  • Returns whether the SDK is currently applying processing.

    Returns boolean

  • onDebugStats(callback: ((stats: { inputClipCount: number; inputClipPeak: number; outputLimiterCount: number; outputLimiterPeak: number; pipelineGainDb: null | number; silentFrames: number; speedupCount: number; speedupDroppedMs: number; underrunCount: number }) => void)): void
  • Parameters

    • callback: ((stats: { inputClipCount: number; inputClipPeak: number; outputLimiterCount: number; outputLimiterPeak: number; pipelineGainDb: null | number; silentFrames: number; speedupCount: number; speedupDroppedMs: number; underrunCount: number }) => void)
        • (stats: { inputClipCount: number; inputClipPeak: number; outputLimiterCount: number; outputLimiterPeak: number; pipelineGainDb: null | number; silentFrames: number; speedupCount: number; speedupDroppedMs: number; underrunCount: number }): void
        • Parameters

          • stats: { inputClipCount: number; inputClipPeak: number; outputLimiterCount: number; outputLimiterPeak: number; pipelineGainDb: null | number; silentFrames: number; speedupCount: number; speedupDroppedMs: number; underrunCount: number }
            • inputClipCount: number
            • inputClipPeak: number
            • outputLimiterCount: number
            • outputLimiterPeak: number
            • pipelineGainDb: null | number
            • silentFrames: number
            • speedupCount: number
            • speedupDroppedMs: number
            • underrunCount: number

          Returns void

    Returns void

  • onError(f: ((e: ErrorObject) => void)): void
  • pass onError callback to ErrorBus

    example
    export interface ErrorObject {
    message: string;
    type: ErrorType;
    code?: ErrorCode;
    emitter?: ErrorEmitter;
    cause?: Error;
    data?: any;
    }

    export enum ErrorCode {
    PERFORMANCE_STOP = 1001, // When the SDK can't perform processing in real-time and latency becomes too high, it will stop processing and bypass the original audio to the output to prevent breaking the user experience and causing audio issues.
    REDUCE_LATENCY = 1002, // When we receive more processed frames than we can render at the moment (this may happen due to short-term performance issues or the browser lowering worker priority), the SDK will increase the speed of the voice (from 10% to 20%) to stabilize latency.
    MODEL_LOAD_FAILED = 1010, // Mostly related to network issues during model loading
    PROCESSOR_INIT_ISSUE = 1020, // Issue during initialization of the ML processor
    AUTH_ISSUE = 1030, // Authentication issue
    SUPPORT_ISSUE = 1040, // Balanced model isn't supported without SIMD support
    PROCESSING_PROGRESS = 1060, // Progress of audio buffer processing
    }

    export enum ErrorType {
    INFO = "info",
    WARNING = "warning",
    ERROR = "error",
    }

    Parameters

    • f: ((e: ErrorObject) => void)

      callback function that takes ErrorObject as its first argument.

        • (e: ErrorObject): void
        • Parameters

          • e: ErrorObject

          Returns void

    Returns void

  • onStudioAudioMetrics(callback: ((metrics: { peak: number; peakDb: number; rms: number; rmsDb: number }) => void)): void
  • Parameters

    • callback: ((metrics: { peak: number; peakDb: number; rms: number; rmsDb: number }) => void)
        • (metrics: { peak: number; peakDb: number; rms: number; rmsDb: number }): void
        • Parameters

          • metrics: { peak: number; peakDb: number; rms: number; rmsDb: number }
            • peak: number
            • peakDb: number
            • rms: number
            • rmsDb: number

          Returns void

    Returns void

  • preload(): Promise<void>
  • Ability to preload all required resourses specified in config. This functionality make the initialization faster. Should be started after all configs are passet to sdk.config

    Returns Promise<void>

  • processBuffer(inputBuffer: Float32Array, sampleRate: number): Promise<Float32Array>
  • Process an audio buffer and return the processed result. Only available when processorType is set to 'buffer'. Uses the current preset and sampleRate from configuration.

    example
    const sdk = new atsvb('customer_id');
    sdk.config({
    processorType: 'buffer',
    preset: 'balanced',
    sample_rate: 32000
    });

    // Process audio buffer
    const inputAudio = new Float32Array(32000); // 1 second at 32kHz
    const processedAudio = await sdk.processBuffer(inputAudio, 32000);

    Parameters

    • inputBuffer: Float32Array

      The Float32Array containing audio samples to process

    • sampleRate: number

      The current sample rate of audio data

    Returns Promise<Float32Array>

    Promise - The processed audio buffer

  • resume(): undefined | false
  • Returns undefined | false

  • run(): void
  • This call starts applying noise reduction effects to the configured audio track. This should be called only after the onReady callback has been triggered.

    Returns void

  • setAudioContext(context: AudioContext): Promise<void>
  • Ability to pass an AudioContext to the SDK. We use it to process audio frames in the Audio Worklet. If a context is not passed, the SDK will create a new context internally.

    Parameters

    • context: AudioContext

    Returns Promise<void>

  • setDenoisePower(power: number): void
  • Set denoise power at runtime. Available only for the balanced preset.

    Parameters

    • power: number

      the number parameter with range 0.0-1.0

    Returns void

  • Configure LSNR-based stage skipping in the denoise model at runtime. Available for the wasm presets (speed and balanced).

    All thresholds are local SNR estimates in dB and must satisfy noiseOnlyLsnrDb <= skipDfLsnrDb <= bypassLsnrDb; they are clamped otherwise.

    Parameters

    Returns void

  • setPreset(preset: ModelType, sampleRate: number): Promise<void>
  • Changes the denoise preset in real-time. Available presets:

    • speed: Supported sample rate - 16000
    • balanced: Supported sample rates - 32000, 44100, 48000
    • quality: Supported sample rate - 16000

    Parameters

    • preset: ModelType

      The preset to use. Default is 'balanced'. Available options: 'speed', 'balanced', 'quality'.

    • sampleRate: number

      The sample rate to use. Default is 32000. Available options: 16000, 32000, 44100, 48000.

      • The 'speed' and 'quality' presets are supported only with a sample rate of 16000.
      • This method reinitializes the audio processing pipeline. During initialization, the SDK will be stopped. After initialization, it will restore the previous state (i.e., it will resume running if it was active before setPreset was called).

    Returns Promise<void>

  • stop(): void
  • This call stops applying noise reduction effects to the configured audio track and bypasses the original audio to the output. So, if you need to disable effects, you can just call stop and not touch the main logic related to WebRTC and MediaStreams. You can enable it again at any time by calling sdk.run().

    Returns void

  • suspend(): undefined | false
  • Returns undefined | false

  • useAudioTrack(track: MediaStreamTrack): void
  • Set the AudioTrack object to be the source of audio frames for processing. This call recreates the entire processing pipeline and loads all required resources. Once everything is loaded, the SDK calls the onReady callback.

    Parameters

    • track: MediaStreamTrack

      the source MediaStreamTrack object.

    Returns void

  • useStream(stream: MediaStream): void
  • Set the MediaStream object to be the source of audio frames for processing. This call recreates the entire processing pipeline and loads all required resources. Once everything is loaded, the SDK calls the onReady callback.

    Parameters

    • stream: MediaStream

      the source MediaStream object.

    Returns void

Generated using TypeDoc