ciyidogan commited on
Commit
65380e4
·
verified ·
1 Parent(s): f68b441

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

Browse files
flare-ui/src/app/components/environment/environment.component.ts CHANGED
@@ -50,6 +50,18 @@ export class EnvironmentComponent implements OnInit {
50
  stt_engine_api_key: ''
51
  };
52
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  loading = true;
54
  saving = false;
55
 
@@ -63,9 +75,9 @@ export class EnvironmentComponent implements OnInit {
63
  next: (env) => {
64
  this.environment = env;
65
 
66
- // Ensure stt_settings exists with defaults
67
- if (!this.environment.stt_settings) {
68
- this.environment.stt_settings = this.getDefaultSTTSettings();
69
  }
70
 
71
  this.loading = false;
@@ -175,99 +187,7 @@ export class EnvironmentComponent implements OnInit {
175
  return '';
176
  }
177
  }
178
-
179
- get sttLanguage(): string {
180
- return this.environment.stt_settings?.language || 'tr-TR';
181
- }
182
-
183
- set sttLanguage(value: string) {
184
- this.ensureSTTSettings();
185
- this.environment.stt_settings!.language = value;
186
- }
187
-
188
- get sttModel(): string {
189
- return this.environment.stt_settings?.model || 'latest_long';
190
- }
191
-
192
- set sttModel(value: string) {
193
- this.ensureSTTSettings();
194
- this.environment.stt_settings!.model = value;
195
- }
196
-
197
- get sttSpeechTimeout(): number {
198
- return this.environment.stt_settings?.speech_timeout_ms || 2000;
199
- }
200
-
201
- set sttSpeechTimeout(value: number) {
202
- this.ensureSTTSettings();
203
- this.environment.stt_settings!.speech_timeout_ms = value;
204
- }
205
-
206
- get sttVadSensitivity(): number {
207
- return this.environment.stt_settings?.vad_sensitivity || 0.5;
208
- }
209
-
210
- set sttVadSensitivity(value: number) {
211
- this.ensureSTTSettings();
212
- this.environment.stt_settings!.vad_sensitivity = value;
213
- }
214
-
215
- get sttNoiseReductionLevel(): number {
216
- return this.environment.stt_settings?.noise_reduction_level || 2;
217
- }
218
-
219
- set sttNoiseReductionLevel(value: number) {
220
- this.ensureSTTSettings();
221
- this.environment.stt_settings!.noise_reduction_level = value;
222
- }
223
-
224
- get sttUseEnhanced(): boolean {
225
- return this.environment.stt_settings?.use_enhanced ?? true;
226
- }
227
-
228
- set sttUseEnhanced(value: boolean) {
229
- this.ensureSTTSettings();
230
- this.environment.stt_settings!.use_enhanced = value;
231
- }
232
-
233
- get sttEnablePunctuation(): boolean {
234
- return this.environment.stt_settings?.enable_punctuation ?? true;
235
- }
236
-
237
- set sttEnablePunctuation(value: boolean) {
238
- this.ensureSTTSettings();
239
- this.environment.stt_settings!.enable_punctuation = value;
240
- }
241
-
242
- get sttInterimResults(): boolean {
243
- return this.environment.stt_settings?.interim_results ?? true;
244
- }
245
-
246
- set sttInterimResults(value: boolean) {
247
- this.ensureSTTSettings();
248
- this.environment.stt_settings!.interim_results = value;
249
- }
250
-
251
- // Helper methods
252
- private ensureSTTSettings(): void {
253
- if (!this.environment.stt_settings) {
254
- this.environment.stt_settings = this.getDefaultSTTSettings();
255
- }
256
- }
257
-
258
- private getDefaultSTTSettings(): STTSettings {
259
- return {
260
- speech_timeout_ms: 2000,
261
- noise_reduction_level: 2,
262
- vad_sensitivity: 0.5,
263
- language: 'tr-TR',
264
- model: 'latest_long',
265
- use_enhanced: true,
266
- enable_punctuation: true,
267
- interim_results: true
268
- };
269
- }
270
-
271
  // formatMilliseconds metodu eksikti, ekleyelim:
272
  formatMilliseconds(value: number): string {
273
  return `${value}ms`;
@@ -275,11 +195,17 @@ export class EnvironmentComponent implements OnInit {
275
 
276
  save() {
277
  this.saving = true;
 
 
 
 
 
 
278
 
279
- this.apiService.updateEnvironment(this.environment).subscribe({
280
  next: () => {
281
  // Environment service'i güncelle
282
- this.environmentService.updateEnvironment(this.environment);
283
 
284
  this.snackBar.open('Environment configuration saved successfully', 'Close', {
285
  duration: 3000
@@ -295,7 +221,7 @@ export class EnvironmentComponent implements OnInit {
295
  this.saving = false;
296
  }
297
  });
298
- }
299
 
300
  testConnection() {
301
  this.snackBar.open('Testing connection to Spark endpoint...', undefined, {
 
50
  stt_engine_api_key: ''
51
  };
52
 
53
+ // Separate STT settings object with defaults
54
+ sttSettings: STTSettings = {
55
+ speech_timeout_ms: 2000,
56
+ noise_reduction_level: 2,
57
+ vad_sensitivity: 0.5,
58
+ language: 'tr-TR',
59
+ model: 'latest_long',
60
+ use_enhanced: true,
61
+ enable_punctuation: true,
62
+ interim_results: true
63
+ };
64
+
65
  loading = true;
66
  saving = false;
67
 
 
75
  next: (env) => {
76
  this.environment = env;
77
 
78
+ // Load STT settings or use defaults
79
+ if (env.stt_settings) {
80
+ this.sttSettings = { ...this.sttSettings, ...env.stt_settings };
81
  }
82
 
83
  this.loading = false;
 
187
  return '';
188
  }
189
  }
190
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  // formatMilliseconds metodu eksikti, ekleyelim:
192
  formatMilliseconds(value: number): string {
193
  return `${value}ms`;
 
195
 
196
  save() {
197
  this.saving = true;
198
+
199
+ // Include STT settings in the save
200
+ const saveData = {
201
+ ...this.environment,
202
+ stt_settings: this.sttSettings
203
+ };
204
 
205
+ this.apiService.updateEnvironment(saveData).subscribe({
206
  next: () => {
207
  // Environment service'i güncelle
208
+ this.environmentService.updateEnvironment(saveData);
209
 
210
  this.snackBar.open('Environment configuration saved successfully', 'Close', {
211
  duration: 3000
 
221
  this.saving = false;
222
  }
223
  });
224
+ }
225
 
226
  testConnection() {
227
  this.snackBar.open('Testing connection to Spark endpoint...', undefined, {