@@ -24,6 +24,8 @@ class OpenAiSettingsService {
24
24
'default_completion_model_id ' => 'string ' ,
25
25
'default_stt_model_id ' => 'string ' ,
26
26
'default_tts_model_id ' => 'string ' ,
27
+ 'tts_voices ' => 'array ' ,
28
+ 'default_tts_voice ' => 'string ' ,
27
29
'default_image_model_id ' => 'string ' ,
28
30
'default_image_size ' => 'string ' ,
29
31
'image_request_auth ' => 'boolean ' ,
@@ -121,10 +123,37 @@ public function getAdminDefaultImageSize(): string {
121
123
return $ this ->appConfig ->getValueString (Application::APP_ID , 'default_image_size ' ) ?: Application::DEFAULT_DEFAULT_IMAGE_SIZE ;
122
124
}
123
125
126
+ /**
127
+ * @return string
128
+ */
124
129
public function getAdminDefaultTtsModelId (): string {
125
130
return $ this ->appConfig ->getValueString (Application::APP_ID , 'default_speech_model_id ' ) ?: Application::DEFAULT_MODEL_ID ;
126
131
}
127
132
133
+ /**
134
+ * @return string
135
+ */
136
+ public function getAdminDefaultTtsVoice (): string {
137
+ return $ this ->appConfig ->getValueString (Application::APP_ID , 'default_speech_voice ' ) ?: Application::DEFAULT_SPEECH_VOICE ;
138
+ }
139
+
140
+ /**
141
+ * @return array
142
+ */
143
+ public function getAdminTtsVoices (): array {
144
+ $ voices = json_decode (
145
+ $ this ->appConfig ->getValueString (
146
+ Application::APP_ID , 'tts_voices ' ,
147
+ json_encode (Application::DEFAULT_SPEECH_VOICES )
148
+ ) ?: json_encode (Application::DEFAULT_SPEECH_VOICES ),
149
+ true ,
150
+ );
151
+ if (!is_array ($ voices )) {
152
+ $ voices = Application::DEFAULT_SPEECH_VOICES ;
153
+ }
154
+ return $ voices ;
155
+ }
156
+
128
157
/**
129
158
* @return string
130
159
*/
@@ -274,6 +303,8 @@ public function getAdminConfig(): array {
274
303
'default_completion_model_id ' => $ this ->getAdminDefaultCompletionModelId (),
275
304
'default_stt_model_id ' => $ this ->getAdminDefaultSttModelId (),
276
305
'default_tts_model_id ' => $ this ->getAdminDefaultTtsModelId (),
306
+ 'default_tts_voice ' => $ this ->getAdminDefaultTtsVoice (),
307
+ 'tts_voices ' => $ this ->getAdminTtsVoices (),
277
308
'default_image_model_id ' => $ this ->getAdminDefaultImageModelId (),
278
309
'default_image_size ' => $ this ->getAdminDefaultImageSize (),
279
310
'image_request_auth ' => $ this ->getIsImageRetrievalAuthenticated (),
@@ -467,6 +498,14 @@ public function setAdminDefaultImageModelId(string $defaultImageModelId): void {
467
498
$ this ->appConfig ->setValueString (Application::APP_ID , 'default_image_model_id ' , $ defaultImageModelId );
468
499
}
469
500
501
+ /**
502
+ * @param string $voice
503
+ * @return void
504
+ */
505
+ public function setAdminDefaultTtsVoice (string $ voice ): void {
506
+ $ this ->appConfig ->setValueString (Application::APP_ID , 'default_speech_voice ' , $ voice );
507
+ }
508
+
470
509
/**
471
510
* @param string $defaultImageSize
472
511
* @return void
@@ -608,6 +647,15 @@ public function setUseBasicAuth(bool $useBasicAuth): void {
608
647
$ this ->invalidateModelsCache ();
609
648
}
610
649
650
+ /**
651
+ * @param array $voices
652
+ * @return void
653
+ */
654
+ public function setAdminTtsVoices (array $ voices ): void {
655
+ $ this ->appConfig ->setValueString (Application::APP_ID , 'tts_voices ' , json_encode ($ voices ));
656
+ $ this ->invalidateModelsCache ();
657
+ }
658
+
611
659
/**
612
660
* Set the admin config for the settings page
613
661
* @param mixed[] $config
@@ -692,6 +740,9 @@ public function setAdminConfig(array $adminConfig): void {
692
740
if (isset ($ adminConfig ['tts_provider_enabled ' ])) {
693
741
$ this ->setTtsProviderEnabled ($ adminConfig ['tts_provider_enabled ' ]);
694
742
}
743
+ if (isset ($ adminConfig ['default_tts_voice ' ])) {
744
+ $ this ->setAdminDefaultTtsVoice ($ adminConfig ['default_tts_voice ' ]);
745
+ }
695
746
if (isset ($ adminConfig ['chat_endpoint_enabled ' ])) {
696
747
$ this ->setChatEndpointEnabled ($ adminConfig ['chat_endpoint_enabled ' ]);
697
748
}
@@ -704,6 +755,9 @@ public function setAdminConfig(array $adminConfig): void {
704
755
if (isset ($ adminConfig ['use_basic_auth ' ])) {
705
756
$ this ->setUseBasicAuth ($ adminConfig ['use_basic_auth ' ]);
706
757
}
758
+ if (isset ($ adminConfig ['tts_voices ' ])) {
759
+ $ this ->setAdminTtsVoices ($ adminConfig ['tts_voices ' ]);
760
+ }
707
761
}
708
762
709
763
/**
0 commit comments