Merge PR #2064: feat(tools): add base_url support to OpenAI TTS provider
Authored by Hanai. Allows overriding the OpenAI TTS endpoint via tts.openai.base_url in config.yaml for self-hosted or OpenAI-compatible TTS services. Falls back to api.openai.com when not set.
This commit is contained in:
commit
efa753678c
2 changed files with 3 additions and 1 deletions
|
|
@ -239,6 +239,7 @@ def _generate_openai_tts(text: str, output_path: str, tts_config: Dict[str, Any]
|
||||||
oai_config = tts_config.get("openai", {})
|
oai_config = tts_config.get("openai", {})
|
||||||
model = oai_config.get("model", DEFAULT_OPENAI_MODEL)
|
model = oai_config.get("model", DEFAULT_OPENAI_MODEL)
|
||||||
voice = oai_config.get("voice", DEFAULT_OPENAI_VOICE)
|
voice = oai_config.get("voice", DEFAULT_OPENAI_VOICE)
|
||||||
|
base_url = oai_config.get("base_url", "https://api.openai.com/v1")
|
||||||
|
|
||||||
# Determine response format from extension
|
# Determine response format from extension
|
||||||
if output_path.endswith(".ogg"):
|
if output_path.endswith(".ogg"):
|
||||||
|
|
@ -247,7 +248,7 @@ def _generate_openai_tts(text: str, output_path: str, tts_config: Dict[str, Any]
|
||||||
response_format = "mp3"
|
response_format = "mp3"
|
||||||
|
|
||||||
OpenAIClient = _import_openai_client()
|
OpenAIClient = _import_openai_client()
|
||||||
client = OpenAIClient(api_key=api_key, base_url="https://api.openai.com/v1")
|
client = OpenAIClient(api_key=api_key, base_url=base_url)
|
||||||
response = client.audio.speech.create(
|
response = client.audio.speech.create(
|
||||||
model=model,
|
model=model,
|
||||||
voice=voice,
|
voice=voice,
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,7 @@ tts:
|
||||||
openai:
|
openai:
|
||||||
model: "gpt-4o-mini-tts"
|
model: "gpt-4o-mini-tts"
|
||||||
voice: "alloy" # alloy, echo, fable, onyx, nova, shimmer
|
voice: "alloy" # alloy, echo, fable, onyx, nova, shimmer
|
||||||
|
base_url: "https://api.openai.com/v1" # optional: override for self-hosted or OpenAI-compatible endpoints
|
||||||
neutts:
|
neutts:
|
||||||
ref_audio: ''
|
ref_audio: ''
|
||||||
ref_text: ''
|
ref_text: ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue