Spaces:
Building
Building
Update flare-ui/src/app/components/environment/environment.component.ts
Browse files
flare-ui/src/app/components/environment/environment.component.ts
CHANGED
@@ -97,6 +97,29 @@ export class EnvironmentComponent implements OnInit {
|
|
97 |
collection_prompt: 'Please provide the following information:'
|
98 |
};
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
constructor(
|
101 |
private fb: FormBuilder,
|
102 |
private apiService: ApiService,
|
@@ -117,7 +140,19 @@ export class EnvironmentComponent implements OnInit {
|
|
117 |
// STT Provider
|
118 |
stt_provider_name: ['no_stt', Validators.required],
|
119 |
stt_provider_api_key: [''],
|
120 |
-
stt_provider_endpoint: ['']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
});
|
122 |
}
|
123 |
|
@@ -197,6 +232,10 @@ export class EnvironmentComponent implements OnInit {
|
|
197 |
if (data.stt_provider?.name !== 'no_stt') {
|
198 |
this.environmentService.setSTTEnabled(true);
|
199 |
}
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
|
202 |
handleLegacyFormat(data: any): void {
|
@@ -222,6 +261,10 @@ export class EnvironmentComponent implements OnInit {
|
|
222 |
this.parameterCollectionConfig = data.parameter_collection_config || this.parameterCollectionConfig;
|
223 |
|
224 |
this.updateCurrentProviders();
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
|
227 |
getDefaultProviders(type: string): ProviderConfig[] {
|
@@ -288,11 +331,29 @@ export class EnvironmentComponent implements OnInit {
|
|
288 |
{
|
289 |
type: 'stt',
|
290 |
name: 'google',
|
291 |
-
display_name: 'Google Cloud
|
292 |
requires_endpoint: false,
|
293 |
requires_api_key: true,
|
294 |
requires_repo_info: false,
|
295 |
-
description: 'Google Cloud Speech-to-Text'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
}
|
297 |
]
|
298 |
};
|
@@ -341,11 +402,19 @@ export class EnvironmentComponent implements OnInit {
|
|
341 |
this.form.get('stt_provider_api_key')?.clearValidators();
|
342 |
}
|
343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
// Update validity
|
345 |
this.form.get('llm_provider_api_key')?.updateValueAndValidity();
|
346 |
this.form.get('llm_provider_endpoint')?.updateValueAndValidity();
|
347 |
this.form.get('tts_provider_api_key')?.updateValueAndValidity();
|
348 |
this.form.get('stt_provider_api_key')?.updateValueAndValidity();
|
|
|
349 |
}
|
350 |
|
351 |
onLLMProviderChange(value: string): void {
|
@@ -368,6 +437,32 @@ export class EnvironmentComponent implements OnInit {
|
|
368 |
if (!this.currentTTSProvider?.requires_api_key) {
|
369 |
this.form.get('tts_provider_api_key')?.setValue('');
|
370 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
|
372 |
// Notify environment service
|
373 |
this.environmentService.setTTSEnabled(value !== 'no_tts');
|
@@ -414,7 +509,7 @@ export class EnvironmentComponent implements OnInit {
|
|
414 |
name: formValue.stt_provider_name,
|
415 |
api_key: formValue.stt_provider_api_key,
|
416 |
endpoint: formValue.stt_provider_endpoint,
|
417 |
-
settings: {}
|
418 |
}
|
419 |
};
|
420 |
|
@@ -510,7 +605,9 @@ export class EnvironmentComponent implements OnInit {
|
|
510 |
case 'tts':
|
511 |
return 'Enter TTS API key';
|
512 |
case 'stt':
|
513 |
-
|
|
|
|
|
514 |
default:
|
515 |
return 'Enter API key';
|
516 |
}
|
|
|
97 |
collection_prompt: 'Please provide the following information:'
|
98 |
};
|
99 |
|
100 |
+
hideSTTKey = true;
|
101 |
+
sttLanguages = [
|
102 |
+
{ code: 'tr-TR', name: 'Türkçe' },
|
103 |
+
{ code: 'en-US', name: 'English (US)' },
|
104 |
+
{ code: 'en-GB', name: 'English (UK)' },
|
105 |
+
{ code: 'de-DE', name: 'Deutsch' },
|
106 |
+
{ code: 'fr-FR', name: 'Français' },
|
107 |
+
{ code: 'es-ES', name: 'Español' },
|
108 |
+
{ code: 'it-IT', name: 'Italiano' },
|
109 |
+
{ code: 'pt-BR', name: 'Português (BR)' },
|
110 |
+
{ code: 'ja-JP', name: '日本語' },
|
111 |
+
{ code: 'ko-KR', name: '한국어' },
|
112 |
+
{ code: 'zh-CN', name: '中文' }
|
113 |
+
];
|
114 |
+
|
115 |
+
sttModels = [
|
116 |
+
{ value: 'default', name: 'Default' },
|
117 |
+
{ value: 'latest_short', name: 'Latest Short (Optimized for short audio)' },
|
118 |
+
{ value: 'latest_long', name: 'Latest Long (Best accuracy)' },
|
119 |
+
{ value: 'command_and_search', name: 'Command and Search' },
|
120 |
+
{ value: 'phone_call', name: 'Phone Call (Optimized for telephony)' }
|
121 |
+
];
|
122 |
+
|
123 |
constructor(
|
124 |
private fb: FormBuilder,
|
125 |
private apiService: ApiService,
|
|
|
140 |
// STT Provider
|
141 |
stt_provider_name: ['no_stt', Validators.required],
|
142 |
stt_provider_api_key: [''],
|
143 |
+
stt_provider_endpoint: [''],
|
144 |
+
|
145 |
+
// STT Settings
|
146 |
+
stt_settings: this.fb.group({
|
147 |
+
language: ['tr-TR'],
|
148 |
+
speech_timeout_ms: [2000],
|
149 |
+
enable_punctuation: [true],
|
150 |
+
interim_results: [true],
|
151 |
+
use_enhanced: [true],
|
152 |
+
model: ['latest_long'],
|
153 |
+
noise_reduction_level: [2],
|
154 |
+
vad_sensitivity: [0.5]
|
155 |
+
})
|
156 |
});
|
157 |
}
|
158 |
|
|
|
232 |
if (data.stt_provider?.name !== 'no_stt') {
|
233 |
this.environmentService.setSTTEnabled(true);
|
234 |
}
|
235 |
+
|
236 |
+
if (data.stt_provider?.settings) {
|
237 |
+
this.form.get('stt_settings')?.patchValue(data.stt_provider.settings);
|
238 |
+
}
|
239 |
}
|
240 |
|
241 |
handleLegacyFormat(data: any): void {
|
|
|
261 |
this.parameterCollectionConfig = data.parameter_collection_config || this.parameterCollectionConfig;
|
262 |
|
263 |
this.updateCurrentProviders();
|
264 |
+
|
265 |
+
if (data.stt_settings) {
|
266 |
+
this.form.get('stt_settings')?.patchValue(data.stt_settings);
|
267 |
+
}
|
268 |
}
|
269 |
|
270 |
getDefaultProviders(type: string): ProviderConfig[] {
|
|
|
331 |
{
|
332 |
type: 'stt',
|
333 |
name: 'google',
|
334 |
+
display_name: 'Google Cloud Speech',
|
335 |
requires_endpoint: false,
|
336 |
requires_api_key: true,
|
337 |
requires_repo_info: false,
|
338 |
+
description: 'Google Cloud Speech-to-Text API'
|
339 |
+
},
|
340 |
+
{
|
341 |
+
type: 'stt',
|
342 |
+
name: 'azure',
|
343 |
+
display_name: 'Azure Speech Services',
|
344 |
+
requires_endpoint: false,
|
345 |
+
requires_api_key: true,
|
346 |
+
requires_repo_info: false,
|
347 |
+
description: 'Azure Cognitive Services Speech'
|
348 |
+
},
|
349 |
+
{
|
350 |
+
type: 'stt',
|
351 |
+
name: 'flicker',
|
352 |
+
display_name: 'Flicker STT',
|
353 |
+
requires_endpoint: true,
|
354 |
+
requires_api_key: true,
|
355 |
+
requires_repo_info: false,
|
356 |
+
description: 'Flicker Speech Recognition Service'
|
357 |
}
|
358 |
]
|
359 |
};
|
|
|
402 |
this.form.get('stt_provider_api_key')?.clearValidators();
|
403 |
}
|
404 |
|
405 |
+
// STT endpoint validator
|
406 |
+
if (this.currentSTTProvider?.requires_endpoint) {
|
407 |
+
this.form.get('stt_provider_endpoint')?.setValidators(Validators.required);
|
408 |
+
} else {
|
409 |
+
this.form.get('stt_provider_endpoint')?.clearValidators();
|
410 |
+
}
|
411 |
+
|
412 |
// Update validity
|
413 |
this.form.get('llm_provider_api_key')?.updateValueAndValidity();
|
414 |
this.form.get('llm_provider_endpoint')?.updateValueAndValidity();
|
415 |
this.form.get('tts_provider_api_key')?.updateValueAndValidity();
|
416 |
this.form.get('stt_provider_api_key')?.updateValueAndValidity();
|
417 |
+
this.form.get('stt_provider_endpoint')?.updateValueAndValidity();
|
418 |
}
|
419 |
|
420 |
onLLMProviderChange(value: string): void {
|
|
|
437 |
if (!this.currentTTSProvider?.requires_api_key) {
|
438 |
this.form.get('tts_provider_api_key')?.setValue('');
|
439 |
}
|
440 |
+
|
441 |
+
if (value !== this.form.get('stt_provider_name')?.value) {
|
442 |
+
this.form.get('stt_provider_api_key')?.setValue('');
|
443 |
+
}
|
444 |
+
|
445 |
+
// Provider-specific defaults
|
446 |
+
if (value === 'google') {
|
447 |
+
this.form.get('stt_settings')?.patchValue({
|
448 |
+
model: 'latest_long',
|
449 |
+
use_enhanced: true
|
450 |
+
});
|
451 |
+
} else if (value === 'azure') {
|
452 |
+
this.form.get('stt_settings')?.patchValue({
|
453 |
+
model: 'default',
|
454 |
+
use_enhanced: false
|
455 |
+
});
|
456 |
+
}
|
457 |
+
|
458 |
+
// STT endpoint validator
|
459 |
+
if (this.currentSTTProvider?.requires_endpoint) {
|
460 |
+
this.form.get('stt_provider_endpoint')?.setValidators(Validators.required);
|
461 |
+
} else {
|
462 |
+
this.form.get('stt_provider_endpoint')?.clearValidators();
|
463 |
+
}
|
464 |
+
|
465 |
+
this.form.get('stt_provider_endpoint')?.updateValueAndValidity();
|
466 |
|
467 |
// Notify environment service
|
468 |
this.environmentService.setTTSEnabled(value !== 'no_tts');
|
|
|
509 |
name: formValue.stt_provider_name,
|
510 |
api_key: formValue.stt_provider_api_key,
|
511 |
endpoint: formValue.stt_provider_endpoint,
|
512 |
+
settings: formValue.stt_settings || {}
|
513 |
}
|
514 |
};
|
515 |
|
|
|
605 |
case 'tts':
|
606 |
return 'Enter TTS API key';
|
607 |
case 'stt':
|
608 |
+
if (this.currentSTTProvider?.name === 'google') return '/path/to/credentials.json';
|
609 |
+
if (this.currentSTTProvider?.name === 'azure') return 'subscription_key|region';
|
610 |
+
return 'Enter STT API key';
|
611 |
default:
|
612 |
return 'Enter API key';
|
613 |
}
|