mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-04-26 01:25:15 +02:00
Add model field parameter for generic OpenAI TTS (#4171)
resolves #4165
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user