UNPKG

js-tts-wrapper

Version:

A JavaScript/TypeScript library that provides a unified API for working with multiple cloud-based Text-to-Speech (TTS) services

91 lines (90 loc) 3.08 kB
/** * SherpaOnnx Native Module Loader * * This module handles loading the sherpa-onnx-node native module with the correct * environment variables set for the current platform. */ /** * Get the current platform key * @returns Platform key for package mapping */ export declare function getCurrentPlatformKey(): string; /** * Get the expected platform package name * @returns Expected package name for current platform */ export declare function getExpectedPlatformPackage(): string | null; /** * Find the sherpa-onnx platform-specific library directory * @returns Path to the library directory or null if not found */ export declare function findSherpaOnnxLibraryPath(): string | null; /** * Check if we're running in ES module or CommonJS context * @returns True if ES modules, false if CommonJS */ export declare function isESModule(): boolean; /** * Set up environment variables for the current platform * @param libraryPath Path to the platform-specific library * @returns True if environment variables were set successfully */ export declare function setupEnvironmentVariables(libraryPath: string): boolean; /** * Generate installation instructions for missing platform packages * @returns Installation instructions string */ export declare function getInstallationInstructions(): string; /** * Load the sherpa-onnx-node module with the correct environment variables * @returns The loaded sherpa-onnx-node module */ export declare function loadSherpaOnnxNode(): Promise<any>; /** * Check if we can run SherpaOnnx in the current environment * @returns Object with detailed environment check results */ export declare function canRunSherpaOnnx(): { canRun: boolean; hasMainPackage: boolean; hasPlatformPackage: boolean; hasNativeModule: boolean; platformKey: string; expectedPackage: string | null; foundLibraryPath: string | null; issues: string[]; }; /** * Simple boolean check for backward compatibility * @returns True if SherpaOnnx can run in the current environment */ export declare function canRunSherpaOnnxSimple(): boolean; /** * Attempt to create platform package symlink/copy for sherpa-onnx-node compatibility * @returns True if workaround was applied successfully */ export declare function applyPlatformPackageWorkaround(): boolean; /** * Get comprehensive diagnostics for SherpaOnnx setup * @returns Detailed diagnostic information */ export declare function getSherpaOnnxDiagnostics(): { platform: string; expectedPackage: string | null; hasMainPackage: boolean; hasPlatformPackage: boolean; hasNativeModule: boolean; environmentVariables: Record<string, string | undefined>; recommendations: string[]; canRun: boolean; }; /** * Create a graceful fallback loader that doesn't throw errors * @returns Object with loaded module or null, plus error information */ export declare function loadSherpaOnnxNodeSafe(): Promise<{ module: any | null; success: boolean; error: Error | null; environmentCheck: ReturnType<typeof canRunSherpaOnnx>; }>;