local multi language STT

This commit is contained in:
2026-03-26 19:38:54 +01:00
parent cc14b4d1b7
commit f2bf70bc7d
18 changed files with 1334 additions and 517 deletions

View File

@@ -4,6 +4,7 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { BrowserSpeechTranscriberService } from './browser-speech-transcriber.service';
import { PeerCallModalComponent } from './peer-call-modal.component';
import { ChatSessionService } from './chat-session.service';
import { JsonFileViewerComponent } from './json-file-viewer.component';
@@ -36,6 +37,7 @@ export class ChatPageComponent implements OnDestroy {
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly ngZone = inject(NgZone);
private readonly speechTranscriber = inject(BrowserSpeechTranscriberService);
private readonly routeParamMap = toSignal(this.route.paramMap, {
initialValue: this.route.snapshot.paramMap,
});
@@ -274,6 +276,10 @@ export class ChatPageComponent implements OnDestroy {
void this.router.navigateByUrl('/');
}
queueMicrotask(() => {
void this.speechTranscriber.preload().catch(() => undefined);
});
effect(() => {
const currentUserId = this.currentUser()?.id ?? null;
this.knownPeers.set(this.readKnownPeers(currentUserId));
@@ -1115,16 +1121,16 @@ export class ChatPageComponent implements OnDestroy {
private async transcribeDictation(blob: Blob, textarea: HTMLTextAreaElement, applyToken: number): Promise<void> {
try {
const transcript = await this.session.requestSpeechTranscription(blob);
const transcript = await this.speechTranscriber.transcribe(blob);
if (applyToken !== this.dictationApplyToken) {
return;
}
this.applyDictatedText(this.mergeDictatedText(this.dictationBaseText, transcript), textarea);
} catch {
} catch (error) {
if (applyToken === this.dictationApplyToken) {
this.session.error.set('Dictation transcription failed.');
this.session.error.set(error instanceof Error ? error.message : 'Dictation transcription failed.');
}
} finally {
if (applyToken === this.dictationApplyToken) {