@@ -183,11 +183,13 @@ export class OutgoingConnection {
183183 private setupBackendHandlers ( backend : TranscriptionBackend ) : void {
184184 backend . onInterimTranscription = ( message ) => {
185185 getInstruments ( ) . transcriptionsReceivedTotal . add ( 1 , { provider : this . options . provider || 'unknown' , is_interim : 'true' } ) ;
186+ this . logTranscriptionSummary ( message , true ) ;
186187 this . onInterimTranscription ?.( message ) ;
187188 } ;
188189
189190 backend . onCompleteTranscription = ( message ) => {
190191 getInstruments ( ) . transcriptionsReceivedTotal . add ( 1 , { provider : this . options . provider || 'unknown' , is_interim : 'false' } ) ;
192+ this . logTranscriptionSummary ( message , false ) ;
191193 this . clearIdleCommitTimeout ( ) ;
192194 this . onCompleteTranscription ?.( message ) ;
193195 } ;
@@ -206,6 +208,18 @@ export class OutgoingConnection {
206208 } ;
207209 }
208210
211+ private logTranscriptionSummary ( message : TranscriptionMessage , isInterim : boolean ) : void {
212+ // DEBUG-only: summarises each transcription arriving from the backend so we
213+ // can tell apart empty end-of-utterance finals from real speech without
214+ // logging full PII. Controlled by LOG_LEVEL=debug.
215+ const segments = message . transcript ?? [ ] ;
216+ const text = segments . map ( ( s ) => s . text ?? '' ) . join ( ' ' ) . trim ( ) ;
217+ const preview = text . length > 40 ? text . slice ( 0 , 40 ) + '…' : text ;
218+ logger . debug (
219+ `Backend ${ isInterim ? 'interim' : 'final' } tag=${ this . localTag } lang=${ message . language ?? 'n/a' } segments=${ segments . length } textLen=${ text . length } preview=${ JSON . stringify ( preview ) } ` ,
220+ ) ;
221+ }
222+
209223 private async reinitializeDecoder ( ) : Promise < void > {
210224 if ( ! this . backend ) {
211225 throw new Error ( 'Cannot initialize decoder without a backend' ) ;
0 commit comments