voice - better tracking of status (#208808)

This commit is contained in:
Benjamin Pasero 2024-03-26 17:47:24 +01:00 committed by GitHub
parent 9d8c22a86c
commit 12b7fd98c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View file

@ -249,7 +249,7 @@ export class EditorDictation extends Disposable implements IEditorContribution {
const cts = new CancellationTokenSource();
disposables.add(toDisposable(() => cts.dispose(true)));
const session = await this.speechService.createSpeechToTextSession(cts.token);
const session = await this.speechService.createSpeechToTextSession(cts.token, 'editor');
disposables.add(session.onDidChange(e => {
if (cts.token.isCancellationRequested) {
return;

View file

@ -147,6 +147,7 @@ export class SpeechService extends Disposable implements ISpeechService {
const sessionStart = Date.now();
let sessionRecognized = false;
let sessionContentLength = 0;
const disposables = new DisposableStore();
@ -163,16 +164,22 @@ export class SpeechService extends Disposable implements ISpeechService {
context: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Context of the session.' };
sessionDuration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Duration of the session.' };
sessionRecognized: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'If speech was recognized.' };
sessionContentLength: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Length of the recognized text.' };
sessionLanguage: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Configured language for the session.' };
};
type SpeechToTextSessionEvent = {
context: string;
sessionDuration: number;
sessionRecognized: boolean;
sessionContentLength: number;
sessionLanguage: string;
};
this.telemetryService.publicLog2<SpeechToTextSessionEvent, SpeechToTextSessionClassification>('speechToTextSession', {
context,
sessionDuration: Date.now() - sessionStart,
sessionRecognized
sessionRecognized,
sessionContentLength,
sessionLanguage: language
});
}
@ -194,9 +201,13 @@ export class SpeechService extends Disposable implements ISpeechService {
}
break;
case SpeechToTextStatus.Recognizing:
case SpeechToTextStatus.Recognized:
sessionRecognized = true;
break;
case SpeechToTextStatus.Recognized:
if (typeof e.text === 'string') {
sessionContentLength += e.text.length;
}
break;
case SpeechToTextStatus.Stopped:
onSessionStoppedOrCanceled();
break;

View file

@ -89,7 +89,7 @@ export class TerminalVoiceSession extends Disposable {
}, voiceTimeout));
this._cancellationTokenSource = new CancellationTokenSource();
this._register(toDisposable(() => this._cancellationTokenSource?.dispose(true)));
const session = await this._speechService.createSpeechToTextSession(this._cancellationTokenSource?.token);
const session = await this._speechService.createSpeechToTextSession(this._cancellationTokenSource?.token, 'terminal');
this._disposables.add(session.onDidChange((e) => {
if (this._cancellationTokenSource?.token.isCancellationRequested) {