Files
stack/apps/api/src/speech/interfaces/stt-provider.interface.ts
T
jason.woltjeandClaude Opus 4.6 af9c5799af fix(#388): address PR review findings — fix WebSocket/REST bugs, improve error handling, fix types and comments
Critical fixes:
- Fix FormData field name mismatch (audio -> file) to match backend FileInterceptor
- Add /speech namespace to WebSocket connection URL
- Pass auth token in WebSocket handshake options
- Wrap audio.play() in try-catch for NotAllowedError and DOMException handling
- Replace bare catch block with named error parameter and descriptive message
- Add connect_error and disconnect event handlers to WebSocket
- Update JSDoc to accurately describe batch transcription (not real-time partial)

Important fixes:
- Emit transcription-error before disconnect in gateway auth failures
- Capture MediaRecorder error details and clean up media tracks on error
- Change TtsDefaultConfig.format type from string to AudioFormat
- Define canonical SPEECH_TIERS and AUDIO_FORMATS arrays as single source of truth
- Fix voice count from 54 to 53 in provider, AGENTS.md, and docs
- Fix inaccurate comments (Piper formats, tier prop, SpeachesProvider, TextValidationPipe)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-15 03:44:33 -06:00

53 lines
1.4 KiB
TypeScript

/**
* STT Provider Interface
*
* Defines the contract for speech-to-text provider implementations.
* All STT providers (e.g., Speaches/faster-whisper) must implement this interface.
*
* Issue #389
*/
import type { TranscribeOptions, TranscriptionResult } from "./speech-types";
/**
* Interface for speech-to-text providers.
*
* Implementations wrap an OpenAI-compatible API endpoint for transcription.
*
* @example
* ```typescript
* class SpeachesSttProvider implements ISTTProvider {
* readonly name = "speaches";
*
* async transcribe(audio: Buffer, options?: TranscribeOptions): Promise<TranscriptionResult> {
* // Call speaches API via OpenAI SDK
* }
*
* async isHealthy(): Promise<boolean> {
* // Check endpoint health
* }
* }
* ```
*/
export interface ISTTProvider {
/** Provider name for logging and identification */
readonly name: string;
/**
* Transcribe audio data to text.
*
* @param audio - Raw audio data as a Buffer
* @param options - Optional transcription parameters
* @returns Transcription result with text and metadata
* @throws {Error} If transcription fails
*/
transcribe(audio: Buffer, options?: TranscribeOptions): Promise<TranscriptionResult>;
/**
* Check if the provider is healthy and available.
*
* @returns true if the provider endpoint is reachable and ready
*/
isHealthy(): Promise<boolean>;
}