Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -53,12 +48,4 @@ public ElevenLabsTextToSpeechOptions getOptions() {
return this.options;
}

public boolean isEnabled() {
return this.enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ private SpringAIModels() {

public static final String DEEPSEEK = "deepseek";

public static final String ELEVEN_LABS = "elevenlabs";

}