Skip to content

Commit

Permalink
Move transcript finalization logic outside webrecognition service
Browse files Browse the repository at this point in the history
  • Loading branch information
jptrsn committed Jan 26, 2025
1 parent 61a1230 commit b67b696
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class RecognitionService {

public disconnectFromStream(streamId: string): void {
this.webRecognition.disconnectFromStream();
if (this.transcriptionEnabled()) {
this.store.dispatch(RecognitionActions.finalizeTranscript());
}
}

public pauseRecognition(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ export class WebRecognitionService {
private SEGMENTATION_DEBOUNCE_MS = 1500;
private NETWORK_ERROR_DEBOUNCE_MS = 1500;
private readonly MAX_RECOGNITION_LENGTH = 15;
private language: Signal<InterfaceLanguage>;
private obsConnected: Signal<boolean | undefined>;
private resultCount: Signal<number | undefined>;
private transcriptionEnabled: Signal<boolean | undefined>;

private isStreaming = false;

constructor(private store: Store<AppState>) {
this.language = toSignal(this.store.select(languageSelector)) as Signal<InterfaceLanguage>;

this.platform = toSignal(this.store.select(platformSelector));
this.obsConnected = toSignal(this.store.pipe(select(selectObsConnected), map((status) => status === ObsConnectionState.connected)));
this.resultCount = toSignal(this.store.select(selectRenderHistoryLength));
Expand Down Expand Up @@ -70,9 +69,7 @@ export class WebRecognitionService {
public disconnectFromStream(): void {
this.isStreaming = false;
this.recog.stop();
if (this.transcriptionEnabled()) {
this.store.dispatch(RecognitionActions.finalizeTranscript());
}

}

public pauseRecognition(): void {
Expand Down Expand Up @@ -149,8 +146,6 @@ export class WebRecognitionService {
this.store.dispatch(RecognitionActions.addTranscriptSegment({ text: partialTranscript, start: segmentStart }))
segmentStart = undefined;
}
// this.historyWorker.postMessage({id: streamId, type: 'put', message: partialTranscript})
// console.log('partialTranscript', partialTranscript)
return current.slice(this.MAX_RECOGNITION_LENGTH * -1);
});
transcript = '';
Expand Down

0 comments on commit b67b696

Please sign in to comment.