# API Reference

Generated from emitted declaration files in `dist/`. Do not edit this file by hand.

## Package Root

Import path: `onnx-asr-web`

### `AsrModel`

Kind: `Class`  
Defined in: `dist/asr-model.d.ts`

```ts
export declare class AsrModel implements AsrTranscriber {
    readonly preprocessor: PreprocessorLike | null;
    readonly encoder: EncoderLike;
    readonly decoder: DecoderLike;
    readonly tokens: TokenVocabulary;
    readonly sampleRate: number;
    constructor({ preprocessor, encoder, decoder, tokens, sampleRate }: AsrModelOptions);
    transcribeSamples(samples: AudioSamples, sampleRate?: number): Promise<TranscriptResult>;
    transcribeWavBuffer(arrayBuffer: ArrayBuffer): Promise<TranscriptResult>;
}
```

### `AsrTranscriber`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Common ASR transcription interface shared by Node and browser loaders.

```ts
export interface AsrTranscriber {
    sampleRate: number;
    transcribeSamples(samples: AudioSamples, sampleRate?: number, options?: Record<string, unknown>): Promise<TranscriptResult>;
    transcribeWavBuffer(arrayBuffer: ArrayBuffer, options?: Record<string, unknown>): Promise<TranscriptResult>;
}
```

### `AudioSamples`

Kind: `TypeAlias`  
Defined in: `dist/types.d.ts`

```ts
export type AudioSamples = Float32Array | number[] | readonly number[];
```

### `CommonModelLoadOptions`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Shared load options accepted by Node and browser model loaders.

```ts
export interface CommonModelLoadOptions {
    quantization?: "int8" | "none" | string;
    sessionOptions?: SessionOptions;
    decoderOptions?: DecoderOptions;
    sampleRate?: number;
    vadModel?: VadDetector | null;
    vad?: VadDetector | null;
    vadOptions?: VadRuntimeOptions;
}
```

### `configureOrtWeb`

Kind: `Function`  
Defined in: `dist/asr-model.d.ts`

Configure ONNX Runtime Web global environment settings.

```ts
export declare function configureOrtWeb(options?: ConfigureOrtWebOptions): void;
```

### `ConfigureOrtWebOptions`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Global ONNX Runtime Web environment options.

```ts
export interface ConfigureOrtWebOptions {
    numThreads?: number;
    wasmPaths?: string | Record<string, string>;
    simd?: boolean;
    proxy?: boolean;
}
```

### `createAsrModel`

Kind: `Function`  
Defined in: `dist/asr-model.d.ts`

Create an ASR model runtime from resolved model files and config.

```ts
export declare function createAsrModel({ modelType, decoderKind, config, preprocessorModel, encoderModel, decoderModel, decoderJointModel, whisperModel, vocabularyText, vocabJson, addedTokensJson, sessionOptions, decoderOptions, }?: CreateAsrModelOptions): Promise<AsrTranscriber>;
```

### `createSileroVadModel`

Kind: `Function`  
Defined in: `dist/vad.d.ts`

Create a Silero VAD model from a local path or URL.

```ts
export declare function createSileroVadModel({ modelPath, sessionOptions, options, }?: {
    modelPath?: string;
    sessionOptions?: ort.InferenceSession.SessionOptions;
    options?: VadRuntimeOptions;
}): Promise<SileroVadModel>;
```

### `DecoderOptions`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Generic decoder tuning supported by transducer loaders.

```ts
export interface DecoderOptions {
    maxSymbols?: number;
}
```

### `detectModelType`

Kind: `Function`  
Defined in: `dist/model-types.d.ts`

Detect model family/runtime spec from parsed config.

```ts
export declare function detectModelType(config: ModelConfig): {
    modelType: string;
    spec: ModelSpec;
};
```

### `MODEL_TYPES`

Kind: `Variable`  
Defined in: `dist/model-types.d.ts`

```ts
MODEL_TYPES: Record<string, ModelSpec>;
```

### `OrtTensor`

Kind: `TypeAlias`  
Defined in: `dist/types.d.ts`

```ts
export type OrtTensor = ort.Tensor;
```

### `parseConfigText`

Kind: `Function`  
Defined in: `dist/model-types.d.ts`

Parse a model `config.json` payload into an object.

```ts
export declare function parseConfigText(configText: string): ModelConfig;
```

### `SegmentTimestamp`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Speech segment timestamp in both samples and seconds.

```ts
export interface SegmentTimestamp {
    start: number;
    end: number;
    startSec: number;
    endSec: number;
}
```

### `SessionOptions`

Kind: `TypeAlias`  
Defined in: `dist/types.d.ts`

```ts
export type SessionOptions = ort.InferenceSession.SessionOptions;
```

### `SileroVadModel`

Kind: `Class`  
Defined in: `dist/vad.d.ts`

```ts
export declare class SileroVadModel {
    readonly session: ort.InferenceSession;
    readonly sampleRate: number;
    readonly threshold: number;
    readonly negThreshold: number;
    readonly minSpeechMs: number;
    readonly minSilenceMs: number;
    readonly speechPadMs: number;
    readonly windowSamples: number;
    readonly inputName: string;
    readonly stateInputName: string;
    readonly srInputName: string;
    readonly outputName: string;
    readonly stateOutputName: string;
    constructor(session: ort.InferenceSession, options?: VadRuntimeOptions);
    initialState(): ort.Tensor;
    speechProbabilities(samples: AudioSamples, sampleRate?: number): Promise<VadSpeechProbabilities>;
    /**
     * Returns speech segments in input sample-rate coordinates.
     * Segment bounds are [start, end), in samples.
     */
    detectSpeechSegments(samples: Float32Array | number[], sampleRate?: number, overrides?: VadRuntimeOptions): Promise<SegmentTimestamp[]>;
}
```

### `TensorData`

Kind: `TypeAlias`  
Defined in: `dist/types.d.ts`

```ts
export type TensorData = ort.Tensor["data"];
```

### `TensorMap`

Kind: `TypeAlias`  
Defined in: `dist/types.d.ts`

```ts
export type TensorMap = ort.InferenceSession.OnnxValueMapType;
```

### `TokenFrame`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Frame-aligned token timing emitted by a decoder.

```ts
export interface TokenFrame {
    startFrame: number;
    endFrame: number;
}
```

### `TranscriptResult`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Normalized transcription result returned by ASR models.

```ts
export interface TranscriptResult {
    text: string;
    tokenIds: number[];
    tokenFrames: TokenFrame[];
    words: WordTimestamp[];
    segments?: SegmentTimestamp[];
}
```

### `VadChunkedAsrModel`

Kind: `Class`  
Defined in: `dist/vad.d.ts`

```ts
export declare class VadChunkedAsrModel {
    readonly baseModel: AsrTranscriber;
    readonly vadModel: VadDetector;
    readonly options: VadRuntimeOptions;
    readonly sampleRate: number;
    constructor(baseModel: AsrTranscriber, vadModel: VadDetector, options?: VadRuntimeOptions);
    transcribeSamples(samples: AudioSamples, sampleRate?: number, options?: Record<string, unknown>): Promise<TranscriptResult>;
    transcribeWavBuffer(arrayBuffer: ArrayBuffer, options?: Record<string, unknown>): Promise<TranscriptResult>;
}
```

### `VadDetector`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Voice activity detector contract used by `withVadModel()`.

```ts
export interface VadDetector {
    sampleRate: number;
    detectSpeechSegments(samples: AudioSamples, sampleRate?: number, overrides?: VadRuntimeOptions): Promise<SegmentTimestamp[]>;
    speechProbabilities?(samples: AudioSamples, sampleRate?: number): Promise<VadSpeechProbabilities>;
}
```

### `VadRuntimeOptions`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Runtime tuning knobs for VAD chunking.

```ts
export interface VadRuntimeOptions {
    sampleRate?: number;
    threshold?: number;
    negThreshold?: number;
    minSpeechMs?: number;
    minSilenceMs?: number;
    speechPadMs?: number;
    windowSamples?: number;
}
```

### `VadSpeechProbabilities`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Raw VAD probability trace over processed windows.

```ts
export interface VadSpeechProbabilities {
    probs: number[];
    processedSamples: number;
}
```

### `withVadModel`

Kind: `Function`  
Defined in: `dist/vad.d.ts`

Wrap an ASR model with VAD-based speech chunking.

```ts
export declare function withVadModel(asrModel: AsrTranscriber, vadModel: VadDetector, options?: VadRuntimeOptions): VadChunkedAsrModel;
```

### `WordTimestamp`

Kind: `Interface`  
Defined in: `dist/types.d.ts`

Word-level timestamp in seconds.

```ts
export interface WordTimestamp {
    word: string;
    start: number;
    end: number;
}
```

## Node Entrypoint

Import path: `onnx-asr-web/node`

### `configureOrtWeb`

Kind: `Function`  
Defined in: `dist/asr-model.d.ts`

Configure ONNX Runtime Web global environment settings.

```ts
export declare function configureOrtWeb(options?: ConfigureOrtWebOptions): void;
```

### `downloadHuggingfaceModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Download an ASR model repo from Hugging Face into local cache.

```ts
export declare function downloadHuggingfaceModel(repoId: string, options?: NodeHuggingFaceOptions): Promise<string>;
```

### `downloadHuggingfaceVadModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Download a VAD model repo from Hugging Face into local cache.

```ts
export declare function downloadHuggingfaceVadModel(repoId: string, options?: NodeHuggingFaceOptions): Promise<string>;
```

### `loadHuggingfaceModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Load an ASR model by Hugging Face repo id.

```ts
export declare function loadHuggingfaceModel(repoId: string, options?: NodeHuggingFaceOptions): Promise<AsrTranscriber>;
```

### `loadHuggingfaceVadModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Load a VAD model by Hugging Face repo id.

```ts
export declare function loadHuggingfaceVadModel(repoId: string, options?: NodeHuggingFaceOptions): Promise<import("./vad.js").SileroVadModel>;
```

### `loadLocalModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Load an ASR model from a local directory.

```ts
export declare function loadLocalModel(modelDir: string, options?: NodeModelLoadOptions): Promise<AsrTranscriber>;
```

### `loadLocalVadModel`

Kind: `Function`  
Defined in: `dist/node.d.ts`

Load a VAD model from a local directory or direct ONNX file path.

```ts
export declare function loadLocalVadModel(modelDir: string, options?: NodeHuggingFaceOptions): Promise<import("./vad.js").SileroVadModel>;
```

### `NodeHuggingFaceOptions`

Kind: `Interface`  
Defined in: `dist/node.d.ts`

Additional Node-only options for downloading from Hugging Face.

```ts
export interface NodeHuggingFaceOptions extends NodeModelLoadOptions {
    fetch?: typeof fetch;
    cacheDir?: string;
    revision?: string;
    endpoint?: string;
    hfToken?: string;
    forceDownload?: boolean;
}
```

### `NodeModelLoadOptions`

Kind: `Interface`  
Defined in: `dist/node.d.ts`

```ts
export interface NodeModelLoadOptions extends CommonModelLoadOptions {
    sessionOptions?: SessionOptions;
    decoderOptions?: DecoderOptions;
    vadModel?: VadDetector | null;
    vad?: VadDetector | null;
    vadOptions?: VadOptions;
}
```

## Browser Entrypoint

Import path: `onnx-asr-web/browser`

### `BrowserModelLoadOptions`

Kind: `Interface`  
Defined in: `dist/browser.d.ts`

Browser loader options for local URLs and Hugging Face model ids.

```ts
export interface BrowserModelLoadOptions extends CommonModelLoadOptions {
    sessionOptions?: SessionOptions;
    decoderOptions?: DecoderOptions;
    vadModel?: VadDetector | null;
    vad?: VadDetector | null;
    vadOptions?: VadOptions;
    headers?: HeadersMap;
    fetch?: typeof fetch;
    whisperModelCandidates?: string[];
    skipRepoListing?: boolean;
    hfToken?: string;
    revision?: string;
    endpoint?: string;
}
```

### `configureOrtWeb`

Kind: `Function`  
Defined in: `dist/asr-model.d.ts`

Configure ONNX Runtime Web global environment settings.

```ts
export declare function configureOrtWeb(options?: ConfigureOrtWebOptions): void;
```

### `loadHuggingfaceModel`

Kind: `Function`  
Defined in: `dist/browser.d.ts`

Load an ASR model by Hugging Face repo id directly in browser.

```ts
export declare function loadHuggingfaceModel(repoId: string, options?: BrowserModelLoadOptions): Promise<AsrTranscriber>;
```

### `loadHuggingfaceVadModel`

Kind: `Function`  
Defined in: `dist/browser.d.ts`

Load a VAD model by Hugging Face repo id directly in browser.

```ts
export declare function loadHuggingfaceVadModel(repoId: string, options?: BrowserModelLoadOptions): Promise<import("./vad.js").SileroVadModel>;
```

### `loadLocalModel`

Kind: `Function`  
Defined in: `dist/browser.d.ts`

Load an ASR model from a browser-accessible base URL.

```ts
export declare function loadLocalModel(baseUrl: string, options?: BrowserModelLoadOptions): Promise<AsrTranscriber>;
```

### `loadLocalVadModel`

Kind: `Function`  
Defined in: `dist/browser.d.ts`

Load a VAD model from a browser-accessible base URL.

```ts
export declare function loadLocalVadModel(baseUrl: string, options?: BrowserModelLoadOptions): Promise<import("./vad.js").SileroVadModel>;
```
