- ai.service: route *.openrouter.ai STT to its JSON+base64 /audio/transcriptions API; keep the OpenAI multipart path (AI SDK) for OpenAI/self-hosted whisper. Unify transcription behind transcribe(). - /transcribe controller: surface the real provider/transport reason (describeProviderError) instead of an opaque 500; preserve HttpException. - testConnection: add an 'stt' capability (silent-WAV probe) + DTO; client gets a Test endpoint button and status dot on the Voice/STT card. - useDictation: log full errors to the console and show the real reason (mic start + transcription paths); handle NotReadable/Abort and missing mediaDevices. - docs(CLAUDE.md): require full error logging + specific user-facing messages.
22 lines
662 B
TypeScript
22 lines
662 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { AiService } from '../../integrations/ai/ai.service';
|
|
|
|
/**
|
|
* Transcribes uploaded audio to text using the per-workspace STT model.
|
|
* Delegates to AiService, which picks the OpenAI-multipart or OpenRouter-JSON
|
|
* path. Never logs the audio or the key.
|
|
*/
|
|
@Injectable()
|
|
export class AiTranscriptionService {
|
|
constructor(private readonly ai: AiService) {}
|
|
|
|
// Transcribe an uploaded audio buffer. `format` is the container hint.
|
|
async transcribe(
|
|
workspaceId: string,
|
|
audio: Uint8Array,
|
|
format: string,
|
|
): Promise<string> {
|
|
return this.ai.transcribe(workspaceId, audio, format);
|
|
}
|
|
}
|