feat(#397): implement WebSocket streaming transcription gateway
All checks were successful
ci/woodpecker/push/api Pipeline was successful

Add SpeechGateway with Socket.IO namespace /speech for real-time
streaming transcription. Supports start-transcription, audio-chunk,
and stop-transcription events with session management, authentication,
and buffer size rate limiting. Includes 29 unit tests covering
authentication, session lifecycle, error handling, cleanup, and
client isolation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 02:54:41 -06:00
parent b3d6d73348
commit 28c9e6fe65
3 changed files with 1058 additions and 2 deletions

View File

@@ -11,15 +11,18 @@
*
* Imports:
* - ConfigModule.forFeature(speechConfig) for speech configuration
* - AuthModule for WebSocket authentication
* - PrismaModule for workspace membership queries
*
* Providers:
* - SpeechService: High-level speech operations with provider selection
* - SpeechGateway: WebSocket gateway for streaming transcription (Issue #397)
* - TTS_PROVIDERS: Map<SpeechTier, ITTSProvider> populated by factory based on config
*
* Exports:
* - SpeechService for use by other modules (e.g., controllers, brain)
*
* Issue #389, #390, #391
* Issue #389, #390, #391, #397
*/
import { Module, type OnModuleInit, Logger } from "@nestjs/common";
@@ -32,15 +35,19 @@ import {
} from "./speech.config";
import { SpeechService } from "./speech.service";
import { SpeechController } from "./speech.controller";
import { SpeechGateway } from "./speech.gateway";
import { STT_PROVIDER, TTS_PROVIDERS } from "./speech.constants";
import { SpeachesSttProvider } from "./providers/speaches-stt.provider";
import { createTTSProviders } from "./providers/tts-provider.factory";
import { AuthModule } from "../auth/auth.module";
import { PrismaModule } from "../prisma/prisma.module";
@Module({
imports: [ConfigModule.forFeature(speechConfig)],
imports: [ConfigModule.forFeature(speechConfig), AuthModule, PrismaModule],
controllers: [SpeechController],
providers: [
SpeechService,
SpeechGateway,
// STT provider: conditionally register SpeachesSttProvider when STT is enabled
...(isSttEnabled()
? [