summarylogtreecommitdiffstats
path: root/feature-local-tts.patch
blob: ced9fe3914e326e498bba00cba0005a382d0322b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/crates/librefang-runtime/src/tts.rs b/crates/librefang-runtime/src/tts.rs
index a50a6fce5..b1ba51eb9 100644
--- a/crates/librefang-runtime/src/tts.rs
+++ b/crates/librefang-runtime/src/tts.rs
@@ -124,9 +124,13 @@ impl TtsEngine {
             "speed": self.config.openai.speed,
         });
 
+        let base_url = self.config.openai.base_url
+            .as_deref()
+            .unwrap_or("https://api.openai.com/v1");
+
         let client = crate::http_client::proxied_client();
         let response = client
-            .post("https://api.openai.com/v1/audio/speech")
+            .post(format!("{}/audio/speech", base_url.trim_end_matches('/')))
             .header("Authorization", format!("Bearer {}", api_key))
             .header("Content-Type", "application/json")
             .json(&body)
diff --git a/crates/librefang-types/src/config/types.rs b/crates/librefang-types/src/config/types.rs
index 1235e6254..5c8c50eab 100644
--- a/crates/librefang-types/src/config/types.rs
+++ b/crates/librefang-types/src/config/types.rs
@@ -1348,6 +1348,8 @@ pub struct TtsOpenAiConfig {
     pub format: String,
     /// Speed: 0.25 to 4.0. Default: 1.0.
     pub speed: f32,
+    /// Custom base URL override for TTS.
+    pub base_url: Option<String>,
 }
 
 impl Default for TtsOpenAiConfig {
@@ -1357,6 +1359,7 @@ impl Default for TtsOpenAiConfig {
             model: "tts-1".to_string(),
             format: "mp3".to_string(),
             speed: 1.0,
+            base_url: None,
         }
     }
 }