diff --git a/public/scripts/extensions/tts/openai-compatible.js b/public/scripts/extensions/tts/openai-compatible.js
index 00b2175ee..0f055f995 100644
--- a/public/scripts/extensions/tts/openai-compatible.js
+++ b/public/scripts/extensions/tts/openai-compatible.js
@@ -18,6 +18,7 @@ class OpenAICompatibleTtsProvider {
speed: 1,
available_voices: ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'],
provider_endpoint: 'http://127.0.0.1:8000/v1/audio/speech',
+ instructions: ''
};
get settingsHtml() {
@@ -37,7 +38,9 @@ class OpenAICompatibleTtsProvider {
<label for="openai_compatible_tts_voices">Available Voices (comma separated):</label>
<input id="openai_compatible_tts_voices" type="text" class="text_pole" value="${this.defaultSettings.available_voices.join()}"/>
<label for="openai_compatible_tts_speed">Speed: <span id="openai_compatible_tts_speed_output"></span></label>
- <input type="range" id="openai_compatible_tts_speed" value="1" min="0.25" max="4" step="0.05">`;
+ <input type="range" id="openai_compatible_tts_speed" value="1" min="0.25" max="4" step="0.05">
+ <label for="openai_compatible_tts_instructions">Instructions (gpt-4o-mini-tts only):</label>
+ <textarea id="openai_compatible_tts_instructions">`;
return html;
}
@@ -72,6 +75,10 @@ class OpenAICompatibleTtsProvider {
this.onSettingsChange();
});
+ $('#openai_compatible_tts_instructions').val(this.settings.instructions);
+ $('#openai_compatible_tts_instructions').on('input', () => {
+ this.onSettingsChange();
+ });
$('#openai_compatible_tts_speed_output').text(this.settings.speed);
$('#openai_compatible_tts_key').toggleClass('success', secret_state[SECRET_KEYS.CUSTOM_OPENAI_TTS]);
@@ -115,6 +122,7 @@ class OpenAICompatibleTtsProvider {
this.settings.model = String($('#openai_compatible_model').val());
this.settings.available_voices = String($('#openai_compatible_tts_voices').val()).split(',');
this.settings.speed = Number($('#openai_compatible_tts_speed').val());
+ this.settings.instructions = String($('#openai_compatible_tts_instructions').val());
$('#openai_compatible_tts_speed_output').text(this.settings.speed);
saveTtsProviderSettings();
}
@@ -178,6 +186,7 @@ class OpenAICompatibleTtsProvider {
model: this.settings.model,
input: inputText,
voice: voiceId,
+ instructions: this.settings.instructions,
response_format: 'mp3',
speed: this.settings.speed,
}),
diff --git a/src/endpoints/openai.js b/src/endpoints/openai.js
index 243b758ed..f5180569b 100644
--- a/src/endpoints/openai.js
+++ b/src/endpoints/openai.js
@@ -305,7 +305,7 @@ const custom = express.Router();
custom.post('/generate-voice', jsonParser, async (request, response) => {
try {
const key = readSecret(request.user.directories, SECRET_KEYS.CUSTOM_OPENAI_TTS);
- const { input, provider_endpoint, response_format, voice, speed, model } = request.body;
+ const { input, provider_endpoint, instructions, response_format, voice, speed, model } = request.body;
if (!provider_endpoint) {
console.warn('No OpenAI-compatible TTS provider endpoint provided');
@@ -323,6 +323,7 @@ custom.post('/generate-voice', jsonParser, async (request, response) => {
response_format: response_format ?? 'mp3',
voice: voice ?? 'alloy',
speed: speed ?? 1,
+ instructions: instructions ?? '',
model: model ?? 'tts-1',
}),
});