Skip to content

Commit d71869e

Browse files
committed
fix: Standardize ElevenLabs auto-configuration conditional property
Squashed 2 commits from PR #4834: - d545de1: 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 <apappascs@gmail.com> - f4835be: fix: update ElevenLabs config tests following openai speach tests Signed-off-by: Alexandros Pappas <apappascs@gmail.com> Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
1 parent 3fc939a commit d71869e

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import org.springframework.ai.elevenlabs.ElevenLabsTextToSpeechModel;
2020
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
21+
import org.springframework.ai.model.SpringAIModelProperties;
22+
import org.springframework.ai.model.SpringAIModels;
2123
import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration;
2224
import org.springframework.beans.factory.ObjectProvider;
2325
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -42,7 +44,7 @@
4244
WebClientAutoConfiguration.class })
4345
@ConditionalOnClass(ElevenLabsApi.class)
4446
@EnableConfigurationProperties({ ElevenLabsSpeechProperties.class, ElevenLabsConnectionProperties.class })
45-
@ConditionalOnProperty(prefix = ElevenLabsSpeechProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
47+
@ConditionalOnProperty(name = SpringAIModelProperties.AUDIO_SPEECH_MODEL, havingValue = SpringAIModels.ELEVEN_LABS,
4648
matchIfMissing = true)
4749
public class ElevenLabsAutoConfiguration {
4850

auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/main/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsSpeechProperties.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ public class ElevenLabsSpeechProperties {
3737

3838
private static final ElevenLabsApi.OutputFormat DEFAULT_OUTPUT_FORMAT = ElevenLabsApi.OutputFormat.MP3_22050_32;
3939

40-
/**
41-
* Enable ElevenLabs speech model.
42-
*/
43-
private boolean enabled = true;
44-
4540
@NestedConfigurationProperty
4641
private final ElevenLabsTextToSpeechOptions options = ElevenLabsTextToSpeechOptions.builder()
4742
.modelId(DEFAULT_MODEL_ID)
@@ -53,12 +48,4 @@ public ElevenLabsTextToSpeechOptions getOptions() {
5348
return this.options;
5449
}
5550

56-
public boolean isEnabled() {
57-
return this.enabled;
58-
}
59-
60-
public void setEnabled(boolean enabled) {
61-
this.enabled = enabled;
62-
}
63-
6451
}

auto-configurations/models/spring-ai-autoconfigure-model-elevenlabs/src/test/java/org/springframework/ai/model/elevenlabs/autoconfigure/ElevenLabsPropertiesTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ public void connectionProperties() {
6262
assertThat(speechProperties.getOptions().getVoiceSettings().style()).isEqualTo(0.2);
6363
assertThat(speechProperties.getOptions().getVoiceSettings().useSpeakerBoost()).isFalse();
6464
assertThat(speechProperties.getOptions().getSpeed()).isEqualTo(1.5f);
65-
66-
// enabled is true by default
67-
assertThat(speechProperties.isEnabled()).isTrue();
6865
});
6966
}
7067

@@ -123,7 +120,7 @@ public void speechActivation() {
123120

124121
// Explicitly enable the text-to-speech autoconfiguration.
125122
new ApplicationContextRunner()
126-
.withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.elevenlabs.tts.enabled=true")
123+
.withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.model.audio.speech=elevenlabs")
127124
.withConfiguration(SpringAiTestAutoConfigurations.of(ElevenLabsAutoConfiguration.class))
128125
.run(context -> {
129126
assertThat(context.getBeansOfType(ElevenLabsSpeechProperties.class)).isNotEmpty();
@@ -132,7 +129,7 @@ public void speechActivation() {
132129

133130
// Explicitly disable the text-to-speech autoconfiguration.
134131
new ApplicationContextRunner()
135-
.withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.elevenlabs.tts.enabled=false")
132+
.withPropertyValues("spring.ai.elevenlabs.api-key=YOUR_API_KEY", "spring.ai.model.audio.speech=none")
136133
.withConfiguration(SpringAiTestAutoConfigurations.of(ElevenLabsAutoConfiguration.class))
137134
.run(context -> {
138135
assertThat(context.getBeansOfType(ElevenLabsSpeechProperties.class)).isEmpty();

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/audio/speech/elevenlabs-speech.adoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,27 @@ The prefix `spring.ai.elevenlabs` is used as the property prefix for *all* Eleve
4848

4949
=== Configuration Properties
5050

51+
[NOTE]
52+
====
53+
Enabling and disabling of the audio speech auto-configurations are now configured via top level properties with the prefix `spring.ai.model.audio.speech`.
54+
55+
To enable, spring.ai.model.audio.speech=elevenlabs (It is enabled by default)
56+
57+
To disable, spring.ai.model.audio.speech=none (or any value which doesn't match elevenlabs)
58+
59+
This change is done to allow configuration of multiple models.
60+
====
61+
5162
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`.
5263

5364
[cols="3,5,2"]
5465
|====
5566
| Property | Description | Default
5667

68+
| spring.ai.model.audio.speech | Enable Audio Speech Model | elevenlabs
5769
| spring.ai.elevenlabs.tts.options.model-id | The ID of the model to use. | eleven_turbo_v2_5
5870
| spring.ai.elevenlabs.tts.options.voice-id | The ID of the voice to use. This is the *voice ID*, not the voice name. | 9BWtsMINqrJLrRacOk9x
5971
| spring.ai.elevenlabs.tts.options.output-format | The output format for the generated audio. See xref:#output-formats[Output Formats] below. | mp3_22050_32
60-
| spring.ai.elevenlabs.tts.enabled | Enable or disable the ElevenLabs Text-to-Speech client. | true
6172
|====
6273

6374
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.

spring-ai-model/src/main/java/org/springframework/ai/model/SpringAIModels.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ private SpringAIModels() {
5858

5959
public static final String DEEPSEEK = "deepseek";
6060

61+
public static final String ELEVEN_LABS = "elevenlabs";
62+
6163
}

0 commit comments

Comments
 (0)