UNPKG

hama-js

Version:

G2P, phoneme-ASR, and P2G inference for Node, Bun, and browsers, powered by a self-contained WASM engine (no onnxruntime).

40 lines (39 loc) 2.23 kB
import { G2PResult, PreserveLiteralsMode } from "./tokenizer.js"; import { PronunciationReplaceOptions, PronunciationReplaceResult, PronunciationScanOptions, PronunciationScanResult, PronunciationTerm } from "./pronunciation.js"; export interface G2POptions { modelPath?: string; encoderModelPath?: string; decoderStepModelPath?: string; maxInputLen?: number; maxOutputLen?: number; } export interface PredictOptions { splitDelimiter?: string | RegExp | null; outputDelimiter?: string; preserveLiterals?: PreserveLiteralsMode; } export declare class G2PNodeModel { private engine; private encHandle; private decHandle; private maxInputLen; private maxOutputLen; private constructor(); static create(options?: G2POptions): Promise<G2PNodeModel>; predict(text: string, options?: PredictOptions): Promise<G2PResult>; pronunciationScan(text: string, terms: Array<string | PronunciationTerm>, options?: PronunciationScanOptions): Promise<PronunciationScanResult>; pronunciationReplace(text: string, terms: Array<string | PronunciationTerm>, options?: PronunciationReplaceOptions): Promise<PronunciationReplaceResult>; getMaxInputLen(): number; private predictSingle; private predictSingleSplit; } export declare const pronunciationScan: (text: string, terms: Array<string | PronunciationTerm>, options?: PronunciationScanOptions) => Promise<PronunciationScanResult>; export declare const pronunciationReplace: (text: string, terms: Array<string | PronunciationTerm>, options?: PronunciationReplaceOptions) => Promise<PronunciationReplaceResult>; export { ASRNodeModel, decodeCtcTokens, } from "./asr.js"; export { ctcPhonemeSpans, ASR_OUTPUT_FRAME_SAMPLES } from "./ctc.js"; export type { PhonemeSpan } from "./ctc.js"; export { P2GNodeModel } from "./p2g.js"; export type { P2GOptions, P2GResult } from "./p2g.js"; export type { P2GAlignment } from "./p2g-text.js"; export type { ASRNodeOptions, ASRResult, CTCDecodeOptions, } from "./asr.js"; export type { PronunciationMatch, PronunciationPatch, PronunciationReplaceOptions, PronunciationReplaceResult, PronunciationScanOptions, PronunciationScanResult, PronunciationTerm, } from "./pronunciation.js";