/** * typeless-sdk * * Convert audio files to polished text using STT + LLM. * * Pipeline: audio file → STT (file upload) → LLM polish (+ vocabulary) → clean text * * Quick start: * ```ts * import { VoiceTextSDK } from 'typeless-sdk'; * * const sdk = new VoiceTextSDK({ * stt: { * endpoint: 'https://api.openai.com/v1/audio/transcriptions', * model: 'whisper-1', * apiKey: process.env.OPENAI_API_KEY!, * }, * llm: { * baseUrl: 'https://api.openai.com/v1', * apiKey: process.env.OPENAI_API_KEY!, * model: 'gpt-4o-mini', * }, * }); * * const { transcript, polishedText } = await sdk.process('/path/to/recording.m4a', { * vocabulary: ['OpenTypeless', 'Tauri'], * language: 'zh', * }); * ``` * * Requires Node.js >= 18. */ export { buildSystemPrompt } from "./prompt"; export type { AppType, BuildPromptOptions, VocabularyEntry } from "./prompt"; export { transcribeAudio } from "./stt"; export type { SttConfig, SttAdapter } from "./stt"; export { polishText } from "./llm"; export type { LlmConfig, PolishOptions } from "./llm"; import { type SttConfig, type SttAdapter } from "./stt"; import { type LlmConfig, type PolishOptions } from "./llm"; import type { AppType, VocabularyEntry } from "./prompt"; export interface SDKConfig { /** * STT provider — either a built-in Whisper-compatible config or a custom adapter function. * * Built-in (Whisper file-upload): * ```ts * stt: { endpoint, model, apiKey, language?, extraFields?, timeoutMs? } * ``` * * Custom adapter (any protocol): * ```ts * stt: async (audio, filename) => myTranscribe(audio, filename) * ``` */ stt: SttConfig | SttAdapter; llm: LlmConfig; } export interface ProcessOptions { /** * Custom vocabulary / dictionary terms. * The LLM will always use these exact spellings in the output. * * For terms that STT frequently mis-transcribes, use `VocabularyEntry` with * `soundsLike` to provide phonetic aliases — the LLM will match and correct * them even when the transcript spelling differs. * * @example * vocabulary: [ * { term: 'OpenTypeless', soundsLike: ['open type less', 'opentypeless'] }, * { term: 'Tauri', soundsLike: ['towery', 'tori'] }, * 'KPI', * ] */ vocabulary?: (string | VocabularyEntry)[]; /** * BCP-47 language code hint for STT (e.g. 'zh', 'en'). * Overrides the language in `stt` config for this call. * Omit or use 'multi' for automatic detection. */ language?: string; /** Context type — affects LLM tone and formatting. Default: 'general' */ appType?: AppType; /** Translate the polished output to another language */ translateEnabled?: boolean; /** BCP-47 target language for translation (e.g. 'en', 'ja') */ targetLang?: string; /** * Called with each streamed LLM token. * When provided, LLM runs in streaming mode. */ onChunk?: (chunk: string) => void; /** * Set to false to skip LLM polishing and return the raw STT transcript. * Default: true */ polish?: boolean; } export interface ProcessResult { /** Raw transcript from STT */ transcript: string; /** LLM-polished text (equals transcript when polish=false) */ polishedText: string; } /** * High-level SDK class combining STT + LLM in a single interface. * * @example * const sdk = new VoiceTextSDK({ * stt: { * endpoint: 'https://api.groq.com/openai/v1/audio/transcriptions', * model: 'whisper-large-v3-turbo', * apiKey: '...', * }, * llm: { * baseUrl: 'https://api.deepseek.com', * apiKey: '...', * model: 'deepseek-chat', * }, * }); * * // One-shot: audio → polished text * const { polishedText } = await sdk.process('meeting.m4a', { * vocabulary: ['季报', 'Q4', 'KPI'], * appType: 'document', * }); * * // Streaming LLM output * await sdk.process('voice-note.wav', { * onChunk: (token) => process.stdout.write(token), * }); */ export declare class VoiceTextSDK { private readonly config; constructor(config: SDKConfig); /** * Transcribe an audio file to raw text via STT. * * @param audio - File path or audio Buffer/Uint8Array * @param filename - Filename hint when audio is a Buffer (used for MIME type) */ transcribe(audio: string | Buffer | Uint8Array, filename?: string): Promise; /** * Polish a raw transcript with the LLM. * * @param rawText - Raw STT transcript * @param options - Vocabulary, context type, translation, streaming */ polish(rawText: string, options?: PolishOptions): Promise; /** * Full pipeline: audio → STT transcript → LLM polished text. * * @param audio - File path or audio Buffer/Uint8Array * @param options - Processing options * @returns Both the raw transcript and the polished text */ process(audio: string | Buffer | Uint8Array, options?: ProcessOptions): Promise; } //# sourceMappingURL=index.d.ts.map