ciyidogan commited on
Commit
213824c
·
verified ·
1 Parent(s): a45d87c

Update flare-ui/src/app/components/environment/environment.component.ts

Browse files
flare-ui/src/app/components/environment/environment.component.ts CHANGED
@@ -198,8 +198,8 @@ import { EnvironmentService } from '../../services/environment.service';
198
 
199
  <!-- STT Settings Panel -->
200
  <mat-expansion-panel class="stt-settings-panel"
201
- *ngIf="environment.stt_engine !== 'no_stt' && environment.stt_settings"
202
- [expanded]="sttSettingsExpanded">
203
  <mat-expansion-panel-header>
204
  <mat-panel-title>
205
  <mat-icon>settings_voice</mat-icon>
@@ -210,13 +210,13 @@ import { EnvironmentService } from '../../services/environment.service';
210
  </mat-panel-description>
211
  </mat-expansion-panel-header>
212
 
213
- <div class="stt-settings-grid">
214
  <mat-form-field appearance="outline">
215
  <mat-label>Speech Timeout (ms)</mat-label>
216
  <input matInput type="number"
217
  name="speechTimeout"
218
- [ngModel]="environment.stt_settings?.speech_timeout_ms || 2000"
219
- (ngModelChange)="updateSTTSetting('speech_timeout_ms', $event)"
220
  min="500" max="5000" step="100"
221
  [disabled]="loading">
222
  <mat-icon matPrefix>timer</mat-icon>
@@ -226,7 +226,8 @@ import { EnvironmentService } from '../../services/environment.service';
226
  <mat-form-field appearance="outline">
227
  <mat-label>Noise Reduction Level</mat-label>
228
  <mat-select name="noiseReduction"
229
- [(ngModel)]="environment.stt_settings!.noise_reduction_level"
 
230
  [disabled]="loading">
231
  <mat-option [value]="0">Off</mat-option>
232
  <mat-option [value]="1">Low</mat-option>
@@ -243,7 +244,8 @@ import { EnvironmentService } from '../../services/environment.service';
243
  [displayWith]="formatVAD">
244
  <input matSliderThumb
245
  name="vadSensitivity"
246
- [(ngModel)]="environment.stt_settings!.vad_sensitivity"
 
247
  [disabled]="loading">
248
  </mat-slider>
249
  <mat-icon matPrefix>graphic_eq</mat-icon>
@@ -253,7 +255,8 @@ import { EnvironmentService } from '../../services/environment.service';
253
  <mat-form-field appearance="outline">
254
  <mat-label>Language</mat-label>
255
  <mat-select name="sttLanguage"
256
- [(ngModel)]="environment.stt_settings!.language"
 
257
  [disabled]="loading">
258
  <mat-option value="tr-TR">Turkish (tr-TR)</mat-option>
259
  <mat-option value="en-US">English (en-US)</mat-option>
@@ -268,7 +271,8 @@ import { EnvironmentService } from '../../services/environment.service';
268
  *ngIf="environment.stt_engine === 'google'">
269
  <mat-label>Model</mat-label>
270
  <mat-select name="sttModel"
271
- [(ngModel)]="environment.stt_settings!.model"
 
272
  [disabled]="loading">
273
  <mat-option value="latest_long">Latest Long (Best for conversations)</mat-option>
274
  <mat-option value="command_and_search">Command & Search (Short queries)</mat-option>
@@ -280,20 +284,23 @@ import { EnvironmentService } from '../../services/environment.service';
280
 
281
  <div class="checkbox-group">
282
  <mat-checkbox name="useEnhanced"
283
- [(ngModel)]="environment.stt_settings!.use_enhanced"
 
284
  [disabled]="loading || environment.stt_engine !== 'google'">
285
  Use Enhanced Model
286
  <mat-icon matTooltip="Better accuracy but higher cost" class="info-icon">info</mat-icon>
287
  </mat-checkbox>
288
 
289
  <mat-checkbox name="enablePunctuation"
290
- [(ngModel)]="environment.stt_settings!.enable_punctuation"
 
291
  [disabled]="loading">
292
  Automatic Punctuation
293
  </mat-checkbox>
294
 
295
  <mat-checkbox name="interimResults"
296
- [(ngModel)]="environment.stt_settings!.interim_results"
 
297
  [disabled]="loading">
298
  Show Interim Results
299
  </mat-checkbox>
@@ -313,7 +320,7 @@ import { EnvironmentService } from '../../services/environment.service';
313
  <p class="cost-info">Cost: ~$0.024/minute (standard), ~$0.036/minute (enhanced)</p>
314
  </div>
315
  </div>
316
- </mat-expansion-panel>
317
 
318
  <mat-expansion-panel class="prompt-panel">
319
  <mat-expansion-panel-header>
@@ -676,6 +683,22 @@ export class EnvironmentComponent implements OnInit {
676
  }
677
  }
678
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  formatVAD(value: number): string {
680
  return value.toFixed(1);
681
  }
@@ -695,27 +718,25 @@ export class EnvironmentComponent implements OnInit {
695
  }
696
  }
697
 
698
- onSTTCredentialsFileSelected(event: any) {
699
- const file = event.target.files[0];
700
- if (file && file.type === 'application/json') {
701
- const reader = new FileReader();
702
- reader.onload = (e: any) => {
703
- try {
704
- // Validate it's a valid JSON
705
- const jsonContent = JSON.parse(e.target.result);
706
- // Store the entire JSON content as the API key
707
- this.environment.stt_engine_api_key = e.target.result;
708
- this.snackBar.open('Google credentials loaded successfully', 'Close', {
709
- duration: 3000
710
- });
711
- } catch (error) {
712
- this.snackBar.open('Invalid JSON file', 'Close', {
713
- duration: 3000,
714
- panelClass: 'error-snackbar'
715
- });
716
- }
717
- };
718
- reader.readAsText(file);
719
  }
720
  }
721
 
 
198
 
199
  <!-- STT Settings Panel -->
200
  <mat-expansion-panel class="stt-settings-panel"
201
+ *ngIf="environment.stt_engine !== 'no_stt'"
202
+ [expanded]="sttSettingsExpanded">
203
  <mat-expansion-panel-header>
204
  <mat-panel-title>
205
  <mat-icon>settings_voice</mat-icon>
 
210
  </mat-panel-description>
211
  </mat-expansion-panel-header>
212
 
213
+ <div class="stt-settings-grid" *ngIf="environment.stt_settings">
214
  <mat-form-field appearance="outline">
215
  <mat-label>Speech Timeout (ms)</mat-label>
216
  <input matInput type="number"
217
  name="speechTimeout"
218
+ [value]="environment.stt_settings.speech_timeout_ms"
219
+ (input)="updateSTTSetting('speech_timeout_ms', +$any($event.target).value)"
220
  min="500" max="5000" step="100"
221
  [disabled]="loading">
222
  <mat-icon matPrefix>timer</mat-icon>
 
226
  <mat-form-field appearance="outline">
227
  <mat-label>Noise Reduction Level</mat-label>
228
  <mat-select name="noiseReduction"
229
+ [value]="environment.stt_settings.noise_reduction_level"
230
+ (selectionChange)="updateSTTSetting('noise_reduction_level', $event.value)"
231
  [disabled]="loading">
232
  <mat-option [value]="0">Off</mat-option>
233
  <mat-option [value]="1">Low</mat-option>
 
244
  [displayWith]="formatVAD">
245
  <input matSliderThumb
246
  name="vadSensitivity"
247
+ [value]="environment.stt_settings.vad_sensitivity"
248
+ (input)="updateSTTSetting('vad_sensitivity', +$any($event.target).value)"
249
  [disabled]="loading">
250
  </mat-slider>
251
  <mat-icon matPrefix>graphic_eq</mat-icon>
 
255
  <mat-form-field appearance="outline">
256
  <mat-label>Language</mat-label>
257
  <mat-select name="sttLanguage"
258
+ [value]="environment.stt_settings.language"
259
+ (selectionChange)="updateSTTSetting('language', $event.value)"
260
  [disabled]="loading">
261
  <mat-option value="tr-TR">Turkish (tr-TR)</mat-option>
262
  <mat-option value="en-US">English (en-US)</mat-option>
 
271
  *ngIf="environment.stt_engine === 'google'">
272
  <mat-label>Model</mat-label>
273
  <mat-select name="sttModel"
274
+ [value]="environment.stt_settings.model"
275
+ (selectionChange)="updateSTTSetting('model', $event.value)"
276
  [disabled]="loading">
277
  <mat-option value="latest_long">Latest Long (Best for conversations)</mat-option>
278
  <mat-option value="command_and_search">Command & Search (Short queries)</mat-option>
 
284
 
285
  <div class="checkbox-group">
286
  <mat-checkbox name="useEnhanced"
287
+ [checked]="environment.stt_settings.use_enhanced"
288
+ (change)="updateSTTSetting('use_enhanced', $event.checked)"
289
  [disabled]="loading || environment.stt_engine !== 'google'">
290
  Use Enhanced Model
291
  <mat-icon matTooltip="Better accuracy but higher cost" class="info-icon">info</mat-icon>
292
  </mat-checkbox>
293
 
294
  <mat-checkbox name="enablePunctuation"
295
+ [checked]="environment.stt_settings.enable_punctuation"
296
+ (change)="updateSTTSetting('enable_punctuation', $event.checked)"
297
  [disabled]="loading">
298
  Automatic Punctuation
299
  </mat-checkbox>
300
 
301
  <mat-checkbox name="interimResults"
302
+ [checked]="environment.stt_settings.interim_results"
303
+ (change)="updateSTTSetting('interim_results', $event.checked)"
304
  [disabled]="loading">
305
  Show Interim Results
306
  </mat-checkbox>
 
320
  <p class="cost-info">Cost: ~$0.024/minute (standard), ~$0.036/minute (enhanced)</p>
321
  </div>
322
  </div>
323
+ </mat-expansion-panel>
324
 
325
  <mat-expansion-panel class="prompt-panel">
326
  <mat-expansion-panel-header>
 
683
  }
684
  }
685
 
686
+ updateSTTSetting(key: string, value: any) {
687
+ if (!this.environment.stt_settings) {
688
+ this.environment.stt_settings = {
689
+ speech_timeout_ms: 2000,
690
+ noise_reduction_level: 2,
691
+ vad_sensitivity: 0.5,
692
+ language: 'tr-TR',
693
+ model: 'latest_long',
694
+ use_enhanced: true,
695
+ enable_punctuation: true,
696
+ interim_results: true
697
+ };
698
+ }
699
+ (this.environment.stt_settings as any)[key] = value;
700
+ }
701
+
702
  formatVAD(value: number): string {
703
  return value.toFixed(1);
704
  }
 
718
  }
719
  }
720
 
721
+ onSTTEngineChange() {
722
+ if (this.environment.stt_engine === 'no_stt') {
723
+ this.environment.stt_engine_api_key = '';
724
+ this.sttSettingsExpanded = false;
725
+ } else {
726
+ // Ensure stt_settings exists when enabling STT
727
+ if (!this.environment.stt_settings) {
728
+ this.environment.stt_settings = {
729
+ speech_timeout_ms: 2000,
730
+ noise_reduction_level: 2,
731
+ vad_sensitivity: 0.5,
732
+ language: 'tr-TR',
733
+ model: 'latest_long',
734
+ use_enhanced: true,
735
+ enable_punctuation: true,
736
+ interim_results: true
737
+ };
738
+ }
739
+ this.sttSettingsExpanded = true;
 
 
740
  }
741
  }
742