UNPKG

phonemize

Version:

Fast phonemizer with rule-based G2P prediction. Pure JavaScript implementation.

15 lines (14 loc) 889 B
/** * Rule-based syllable engine for English G2P. * * Pure functions + their data tables, extracted verbatim from * en-g2p.ts: Maximal-Onset syllabification, morphology/weight-driven * stress assignment, and per-syllable IPA conversion (SUFFIX_RULES / * PHONEME_RULES, first match wins — order is load-bearing). */ import type { TraceStep } from "./g2p"; export declare function syllabify(word: string): string[]; export declare function assignStress(syllables: string[], word: string): number; export declare function isSyllableHeavy(syllable: string): boolean; export declare function isLikelyCompound(word: string, syllables: string[]): boolean; export declare function syllableToIPA(syllable: string, syllableIndex: number, isStressed: boolean, isLastSyllable: boolean, nextSyllable?: string, steps?: TraceStep[], prevSyllable?: string, isNextLastSyllable?: boolean): string;