js-tts-wrapper
Version:
A JavaScript/TypeScript library that provides a unified API for working with multiple cloud-based Text-to-Speech (TTS) services
68 lines (67 loc) • 1.86 kB
TypeScript
/**
* Language utilities for normalizing language codes across different formats
*/
/**
* Standardized language information across all TTS engines
*/
export interface StandardizedLanguage {
/**
* ISO 639-3 language code (3-letter)
*/
iso639_3: string;
/**
* BCP-47 language tag
*/
bcp47: string;
/**
* Human-readable display name
*/
display: string;
/**
* Country/region code (if applicable)
*/
countryCode?: string;
}
/**
* Language normalization utilities
*/
export declare class LanguageNormalizer {
/**
* Common language display names
*/
private static readonly languageNames;
/**
* Common region display names
*/
private static readonly regionNames;
/**
* ISO 639-1 to ISO 639-3 mapping
*/
private static readonly iso1To3;
/**
* Normalize a language code to standard formats
* @param langCode Input language code (can be ISO639-1/2/3, BCP47, or locale)
* @param countryCode Optional country code to help with regionalization
* @returns StandardizedLanguage object containing normalized codes
*/
static normalize(langCode: string, countryCode?: string): StandardizedLanguage;
/**
* Get the display name for a language code
* @param langCode Language code
* @returns Display name
*/
static getDisplayName(langCode: string): string;
/**
* Get the ISO 639-3 code for a language code
* @param langCode Language code
* @returns ISO 639-3 code
*/
static getISO639_3(langCode: string): string;
/**
* Get the BCP-47 tag for a language code
* @param langCode Language code
* @param countryCode Optional country code
* @returns BCP-47 tag
*/
static getBCP47(langCode: string, countryCode?: string): string;
}