From d545de11a773e42d4f5f3b8f21cf818a769fa6f2 Mon Sep 17 00:00:00 2001 From: Alexandros Pappas Date: Mon, 10 Nov 2025 00:47:51 +0100 Subject: [PATCH 1/2] fix: Standardize ElevenLabs auto-configuration conditional property Update ElevenLabsAutoConfiguration to use the standardized SpringAIModelProperties AUDIO_SPEECH_MODEL property instead of the provider-specific enabled property. Signed-off-by: Alexandros Pappas --- .../autoconfigure/ElevenLabsAutoConfiguration.java | 4 +++- .../pages/api/audio/speech/elevenlabs-speech.adoc | 13 ++++++++++++- .../springframework/ai/model/SpringAIModels.java | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsAutoConfiguration.java b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsAutoConfiguration.java index bbff2dcf71e..0c8fa715b6a 100644 --- a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsAutoConfiguration.java +++ b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsAutoConfiguration.java @@ -18,6 +18,8 @@ import org.springframework.ai.elevenlabs.ElevenLabsTextToSpeechModel; import org.springframework.ai.elevenlabs.api.ElevenLabsApi; +import org.springframework.ai.model.SpringAIModelProperties; +import org.springframework.ai.model.SpringAIModels; import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -42,7 +44,7 @@ WebClientAutoConfiguration.class }) @ConditionalOnClass(ElevenLabsApi.class) @EnableConfigurationProperties({ ElevenLabsSpeechProperties.class, ElevenLabsConnectionProperties.class }) -@ConditionalOnProperty(prefix = ElevenLabsSpeechProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", +@ConditionalOnProperty(name = SpringAIModelProperties.AUDIO_SPEECH_MODEL, havingValue = SpringAIModels.ELEVEN_LABS, matchIfMissing = true) public class ElevenLabsAutoConfiguration { diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/audio/speech/elevenlabs-speech.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/audio/speech/elevenlabs-speech.adoc index e48457327c2..d680e1fb127 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/audio/speech/elevenlabs-speech.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/audio/speech/elevenlabs-speech.adoc @@ -48,16 +48,27 @@ The prefix `spring.ai.elevenlabs` is used as the property prefix for *all* Eleve === Configuration Properties +[NOTE] +==== +Enabling and disabling of the audio speech auto-configurations are now configured via top level properties with the prefix `spring.ai.model.audio.speech`. + +To enable, spring.ai.model.audio.speech=elevenlabs (It is enabled by default) + +To disable, spring.ai.model.audio.speech=none (or any value which doesn't match elevenlabs) + +This change is done to allow configuration of multiple models. +==== + The prefix `spring.ai.elevenlabs.tts` is used as the property prefix to configure the ElevenLabs Text-to-Speech client, specifically. This is defined in `ElevenLabsSpeechProperties`. [cols="3,5,2"] |==== | Property | Description | Default +| spring.ai.model.audio.speech | Enable Audio Speech Model | elevenlabs | spring.ai.elevenlabs.tts.options.model-id | The ID of the model to use. | eleven_turbo_v2_5 | spring.ai.elevenlabs.tts.options.voice-id | The ID of the voice to use. This is the *voice ID*, not the voice name. | 9BWtsMINqrJLrRacOk9x | spring.ai.elevenlabs.tts.options.output-format | The output format for the generated audio. See xref:#output-formats[Output Formats] below. | mp3_22050_32 -| spring.ai.elevenlabs.tts.enabled | Enable or disable the ElevenLabs Text-to-Speech client. | true |==== NOTE: The base URL and API key can also be configured *specifically* for TTS using `spring.ai.elevenlabs.tts.base-url` and `spring.ai.elevenlabs.tts.api-key`. However, it is generally recommended to use the global `spring.ai.elevenlabs` prefix for simplicity, unless you have a specific reason to use different credentials for different ElevenLabs services. The more specific `tts` properties will override the global ones. diff --git a/spring-ai-model/src/main/java/org/springframework/ai/model/SpringAIModels.java b/spring-ai-model/src/main/java/org/springframework/ai/model/SpringAIModels.java index 63f0cdc32e8..19f8a8a3258 100644 --- a/spring-ai-model/src/main/java/org/springframework/ai/model/SpringAIModels.java +++ b/spring-ai-model/src/main/java/org/springframework/ai/model/SpringAIModels.java @@ -58,4 +58,6 @@ private SpringAIModels() { public static final String DEEPSEEK = "deepseek"; + public static final String ELEVEN_LABS = "elevenlabs"; + } From f4835be8107b924d19fd1fcd021b1b5513c2228e Mon Sep 17 00:00:00 2001 From: Alexandros Pappas Date: Mon, 10 Nov 2025 01:10:10 +0100 Subject: [PATCH 2/2] fix: update ElevenLabs config tests following openai speach tests Signed-off-by: Alexandros Pappas --- .../autoconfigure/ElevenLabsSpeechProperties.java | 13 ------------- .../autoconfigure/ElevenLabsPropertiesTests.java | 7 ++----- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsSpeechProperties.java b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsSpeechProperties.java index 46a87939366..8d3847ab00a 100644 --- a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsSpeechProperties.java +++ b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsSpeechProperties.java @@ -37,11 +37,6 @@ public class ElevenLabsSpeechProperties { private static final ElevenLabsApi.OutputFormat DEFAULT_OUTPUT_FORMAT = ElevenLabsApi.OutputFormat.MP3_22050_32; - /** - * Enable ElevenLabs speech model. - */ - private boolean enabled = true; - @NestedConfigurationProperty private final ElevenLabsTextToSpeechOptions options = ElevenLabsTextToSpeechOptions.builder() .modelId(DEFAULT_MODEL_ID) @@ -53,12 +48,4 @@ public ElevenLabsTextToSpeechOptions getOptions() { return this.options; } - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - } diff --git a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/test/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsPropertiesTests.java b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/test/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsPropertiesTests.java index 08b5f6e4c38..7061260b097 100644 --- a/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/test/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsPropertiesTests.java +++ b/auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/test/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsPropertiesTests.java @@ -62,9 +62,6 @@ public void connectionProperties() { assertThat(speechProperties.getOptions().getVoiceSettings().style()).isEqualTo(0.2); assertThat(speechProperties.getOptions().getVoiceSettings().useSpeakerBoost()).isFalse(); assertThat(speechProperties.getOptions().getSpeed()).isEqualTo(1.5f); - - // enabled is true by default - assertThat(speechProperties.isEnabled()).isTrue(); }); } @@ -123,7 +120,7 @@ public void speechActivation() { // Explicitly enable the text-to-speech autoconfiguration. new ApplicationContextRunner() - .withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.elevenlabs.tts.enabled=true") + .withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.model.audio.speech=elevenlabs") .withConfiguration(SpringAiTestAutoConfigurations.of(ElevenLabsAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(ElevenLabsSpeechProperties.class)).isNotEmpty(); @@ -132,7 +129,7 @@ public void speechActivation() { // Explicitly disable the text-to-speech autoconfiguration. new ApplicationContextRunner() - .withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.elevenlabs.tts.enabled=false") + .withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.model.audio.speech=none") .withConfiguration(SpringAiTestAutoConfigurations.of(ElevenLabsAutoConfiguration.class)) .run(context -> { assertThat(context.getBeansOfType(ElevenLabsSpeechProperties.class)).isEmpty();