Add model field parameter for generic OpenAI TTS (#4171)

resolves #4165
This commit is contained in:
Timothy Carambat
2025-07-17 10:28:51 -07:00
committed by GitHub
parent ff34c8cefc
commit 043cb1d085
6 changed files with 40 additions and 4 deletions

View File

@@ -4,6 +4,10 @@ class GenericOpenAiTTS {
this.#log(
"No OpenAI compatible API key was set. You might need to set this to use your OpenAI compatible TTS service."
);
if (!process.env.TTS_OPEN_AI_COMPATIBLE_MODEL)
this.#log(
"No OpenAI compatible TTS model was set. We will use the default voice model 'tts-1'. This may not exist or be valid your selected endpoint."
);
if (!process.env.TTS_OPEN_AI_COMPATIBLE_VOICE_MODEL)
this.#log(
"No OpenAI compatible voice model was set. We will use the default voice model 'alloy'. This may not exist for your selected endpoint."
@@ -18,7 +22,11 @@ class GenericOpenAiTTS {
apiKey: process.env.TTS_OPEN_AI_COMPATIBLE_KEY || null,
baseURL: process.env.TTS_OPEN_AI_COMPATIBLE_ENDPOINT,
});
this.model = process.env.TTS_OPEN_AI_COMPATIBLE_MODEL ?? "tts-1";
this.voice = process.env.TTS_OPEN_AI_COMPATIBLE_VOICE_MODEL ?? "alloy";
this.#log(
`Service (${process.env.TTS_OPEN_AI_COMPATIBLE_ENDPOINT}) with model: ${this.model} and voice: ${this.voice}`
);
}
#log(text, ...args) {
@@ -33,7 +41,7 @@ class GenericOpenAiTTS {
async ttsBuffer(textInput) {
try {
const result = await this.openai.audio.speech.create({
model: "tts-1",
model: this.model,
voice: this.voice,
input: textInput,
});