Skip to content

Commit 01507f3

Browse files
committed
feat: rebase with master and update the code
Signed-off-by: Alexandros Pappas <[email protected]>
1 parent f627e41 commit 01507f3

File tree

35 files changed

+240
-108
lines changed

35 files changed

+240
-108
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.springframework.ai</groupId>
8+
<artifactId>spring-ai-parent</artifactId>
9+
<version>1.1.0-SNAPSHOT</version>
10+
<relativePath>../../../pom.xml</relativePath>
11+
</parent>
12+
<artifactId>spring-ai-autoconfigure-model-elevenlabs</artifactId>
13+
<packaging>jar</packaging>
14+
<name>Spring AI ElevenLabs Auto Configuration</name>
15+
<description>Spring AI ElevenLabs Auto Configuration</description>
16+
<url>https://github.com/spring-projects/spring-ai</url>
17+
18+
<scm>
19+
<url>https://github.com/spring-projects/spring-ai</url>
20+
<connection>git://github.com/spring-projects/spring-ai.git</connection>
21+
<developerConnection>[email protected]:spring-projects/spring-ai.git</developerConnection>
22+
</scm>
23+
24+
25+
<dependencies>
26+
27+
<!-- Spring AI dependencies -->
28+
29+
<dependency>
30+
<groupId>org.springframework.ai</groupId>
31+
<artifactId>spring-ai-elevenlabs</artifactId>
32+
<version>${project.parent.version}</version>
33+
<optional>true</optional>
34+
</dependency>
35+
36+
<!-- Spring AI auto configurations -->
37+
38+
<dependency>
39+
<groupId>org.springframework.ai</groupId>
40+
<artifactId>spring-ai-autoconfigure-model-tool</artifactId>
41+
<version>${project.parent.version}</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>org.springframework.ai</groupId>
46+
<artifactId>spring-ai-autoconfigure-retry</artifactId>
47+
<version>${project.parent.version}</version>
48+
</dependency>
49+
50+
<!-- Boot dependencies -->
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-starter</artifactId>
54+
<optional>true</optional>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-configuration-processor</artifactId>
60+
<optional>true</optional>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
66+
<optional>true</optional>
67+
</dependency>
68+
69+
<!-- Test dependencies -->
70+
<dependency>
71+
<groupId>org.springframework.ai</groupId>
72+
<artifactId>spring-ai-test</artifactId>
73+
<version>${project.parent.version}</version>
74+
<scope>test</scope>
75+
</dependency>
76+
77+
<dependency>
78+
<groupId>org.springframework.boot</groupId>
79+
<artifactId>spring-boot-starter-test</artifactId>
80+
<scope>test</scope>
81+
</dependency>
82+
83+
<dependency>
84+
<groupId>org.mockito</groupId>
85+
<artifactId>mockito-core</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
</dependencies>
89+
90+
</project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.autoconfigure.elevenlabs;
17+
package org.springframework.ai.model.elevenlabs.autoconfigure;
1818

19-
import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration;
2019
import org.springframework.ai.elevenlabs.ElevenLabsTextToSpeechModel;
2120
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
21+
import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration;
2222
import org.springframework.beans.factory.ObjectProvider;
2323
import org.springframework.boot.autoconfigure.AutoConfiguration;
2424
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.autoconfigure.elevenlabs;
17+
package org.springframework.ai.model.elevenlabs.autoconfigure;
1818

1919
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
2020
import org.springframework.boot.context.properties.ConfigurationProperties;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.autoconfigure.elevenlabs;
17+
package org.springframework.ai.model.elevenlabs.autoconfigure;
1818

1919
import org.springframework.ai.elevenlabs.ElevenLabsTextToSpeechOptions;
2020
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
@@ -31,7 +31,7 @@ public class ElevenLabsSpeechProperties {
3131

3232
public static final String CONFIG_PREFIX = "spring.ai.elevenlabs.tts";
3333

34-
public static final String DEFAULT_MODEL_ID = "eleven_monolingual_v1";
34+
public static final String DEFAULT_MODEL_ID = "eleven_turbo_v2_5";
3535

3636
private static final String DEFAULT_VOICE_ID = "9BWtsMINqrJLrRacOk9x";
3737

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright 2025-2025 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
org.springframework.ai.model.elevenlabs.autoconfigure.elevenlabsChatAutoConfiguration
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.autoconfigure.elevenlabs;
17+
package org.springframework.ai.model.elevenlabs.autoconfigure;
1818

1919
import java.util.Arrays;
2020

@@ -72,14 +72,13 @@ void speechStream() {
7272
}
7373

7474
public boolean verifyMp3FrameHeader(byte[] audioResponse) {
75-
// Check if the response is null or too short to contain a frame header
76-
if (audioResponse == null || audioResponse.length < 2) {
75+
if (audioResponse == null || audioResponse.length < 3) {
7776
return false;
7877
}
79-
// Check for the MP3 frame header
80-
// 0xFFE0 is the sync word for an MP3 frame (11 bits set to 1 followed by 3 bits
81-
// set to 0)
82-
return (audioResponse[0] & 0xFF) == 0xFF && (audioResponse[1] & 0xE0) == 0xE0;
78+
// Accept ID3 tag (MP3 metadata) or MP3 frame header
79+
boolean hasId3 = audioResponse[0] == 'I' && audioResponse[1] == 'D' && audioResponse[2] == '3';
80+
boolean hasFrame = (audioResponse[0] & 0xFF) == 0xFF && (audioResponse[1] & 0xE0) == 0xE0;
81+
return hasId3 || hasFrame;
8382
}
8483

8584
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ai.autoconfigure.elevenlabs;
17+
package org.springframework.ai.model.elevenlabs.autoconfigure;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import org.junit.jupiter.api.Test;
@@ -83,8 +83,8 @@ public void speechOptionsTest() {
8383
"spring.ai.elevenlabs.tts.options.seed=12345",
8484
"spring.ai.elevenlabs.tts.options.previous-text=previous",
8585
"spring.ai.elevenlabs.tts.options.next-text=next",
86-
"spring.ai.elevenlabs.tts.options.use-pvc-as-ivc=true",
87-
"spring.ai.elevenlabs.tts.options.apply-text-normalization=ON"
86+
"spring.ai.elevenlabs.tts.options.apply-text-normalization=ON",
87+
"spring.ai.elevenlabs.tts.options.apply-language-text-normalization=true"
8888
// @formatter:on
8989
).withConfiguration(AutoConfigurations.of(ElevenLabsAutoConfiguration.class)).run(context -> {
9090
var speechProperties = context.getBean(ElevenLabsSpeechProperties.class);
@@ -102,9 +102,9 @@ public void speechOptionsTest() {
102102
assertThat(speechProperties.getOptions().getSeed()).isEqualTo(12345);
103103
assertThat(speechProperties.getOptions().getPreviousText()).isEqualTo("previous");
104104
assertThat(speechProperties.getOptions().getNextText()).isEqualTo("next");
105-
assertThat(speechProperties.getOptions().getUsePvcAsIvc()).isTrue();
106105
assertThat(speechProperties.getOptions().getApplyTextNormalization())
107106
.isEqualTo(ElevenLabsApi.SpeechRequest.TextNormalizationMode.ON);
107+
assertThat(speechProperties.getOptions().getApplyLanguageTextNormalization()).isTrue();
108108
});
109109
}
110110

models/spring-ai-elevenlabs/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<modelVersion>4.0.0</modelVersion>
66
<parent>
77
<groupId>org.springframework.ai</groupId>
8-
<artifactId>spring-ai</artifactId>
9-
<version>1.0.0-SNAPSHOT</version>
8+
<artifactId>spring-ai-parent</artifactId>
9+
<version>1.1.0-SNAPSHOT</version>
1010
<relativePath>../../pom.xml</relativePath>
1111
</parent>
1212

@@ -31,7 +31,7 @@
3131
<!-- production dependencies -->
3232
<dependency>
3333
<groupId>org.springframework.ai</groupId>
34-
<artifactId>spring-ai-core</artifactId>
34+
<artifactId>spring-ai-model</artifactId>
3535
<version>${project.parent.version}</version>
3636
</dependency>
3737

models/spring-ai-elevenlabs/src/main/java/org/springframework/ai/elevenlabs/ElevenLabsTextToSpeechModel.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
import reactor.core.publisher.Flux;
2424

2525
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
26-
import org.springframework.ai.elevenlabs.tts.Speech;
27-
import org.springframework.ai.elevenlabs.tts.StreamingTextToSpeechModel;
28-
import org.springframework.ai.elevenlabs.tts.TextToSpeechModel;
29-
import org.springframework.ai.elevenlabs.tts.TextToSpeechPrompt;
30-
import org.springframework.ai.elevenlabs.tts.TextToSpeechResponse;
26+
import org.springframework.ai.audio.tts.Speech;
27+
import org.springframework.ai.audio.tts.StreamingTextToSpeechModel;
28+
import org.springframework.ai.audio.tts.TextToSpeechModel;
29+
import org.springframework.ai.audio.tts.TextToSpeechPrompt;
30+
import org.springframework.ai.audio.tts.TextToSpeechResponse;
3131
import org.springframework.ai.retry.RetryUtils;
3232
import org.springframework.retry.support.RetryTemplate;
3333
import org.springframework.util.Assert;
@@ -131,8 +131,8 @@ private ElevenLabsApi.SpeechRequest createRequest(TextToSpeechPrompt prompt) {
131131
.nextText(options.getNextText())
132132
.previousRequestIds(options.getPreviousRequestIds())
133133
.nextRequestIds(options.getNextRequestIds())
134-
.usePvcAsIvc(options.getUsePvcAsIvc())
135134
.applyTextNormalization(options.getApplyTextNormalization())
135+
.applyLanguageTextNormalization(options.getApplyLanguageTextNormalization())
136136
.build();
137137
}
138138

@@ -161,9 +161,10 @@ private ElevenLabsTextToSpeechOptions merge(ElevenLabsTextToSpeechOptions runtim
161161
.previousRequestIds(
162162
getOrDefault(runtimeOptions.getPreviousRequestIds(), defaultOptions.getPreviousRequestIds()))
163163
.nextRequestIds(getOrDefault(runtimeOptions.getNextRequestIds(), defaultOptions.getNextRequestIds()))
164-
.usePvcAsIvc(getOrDefault(runtimeOptions.getUsePvcAsIvc(), defaultOptions.getUsePvcAsIvc()))
165164
.applyTextNormalization(getOrDefault(runtimeOptions.getApplyTextNormalization(),
166165
defaultOptions.getApplyTextNormalization()))
166+
.applyLanguageTextNormalization(getOrDefault(runtimeOptions.getApplyLanguageTextNormalization(),
167+
defaultOptions.getApplyLanguageTextNormalization()))
167168
.build();
168169
}
169170

models/spring-ai-elevenlabs/src/main/java/org/springframework/ai/elevenlabs/ElevenLabsTextToSpeechOptions.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.fasterxml.jackson.annotation.JsonProperty;
2525

2626
import org.springframework.ai.elevenlabs.api.ElevenLabsApi;
27-
import org.springframework.ai.elevenlabs.tts.TextToSpeechOptions;
27+
import org.springframework.ai.audio.tts.TextToSpeechOptions;
2828

2929
/**
3030
* Options for ElevenLabs text-to-speech.
@@ -76,12 +76,12 @@ public class ElevenLabsTextToSpeechOptions implements TextToSpeechOptions {
7676
@JsonProperty("next_request_ids")
7777
private List<String> nextRequestIds;
7878

79-
@JsonProperty("use_pvc_as_ivc")
80-
private Boolean usePvcAsIvc;
81-
8279
@JsonProperty("apply_text_normalization")
8380
private ElevenLabsApi.SpeechRequest.TextNormalizationMode applyTextNormalization;
8481

82+
@JsonProperty("apply_language_text_normalization")
83+
private Boolean applyLanguageTextNormalization;
84+
8585
public static Builder builder() {
8686
return new ElevenLabsTextToSpeechOptions.Builder();
8787
}
@@ -246,14 +246,6 @@ public void setNextRequestIds(List<String> nextRequestIds) {
246246
this.nextRequestIds = nextRequestIds;
247247
}
248248

249-
public Boolean getUsePvcAsIvc() {
250-
return this.usePvcAsIvc;
251-
}
252-
253-
public void setUsePvcAsIvc(Boolean usePvcAsIvc) {
254-
this.usePvcAsIvc = usePvcAsIvc;
255-
}
256-
257249
public ElevenLabsApi.SpeechRequest.TextNormalizationMode getApplyTextNormalization() {
258250
return this.applyTextNormalization;
259251
}
@@ -262,6 +254,14 @@ public void setApplyTextNormalization(ElevenLabsApi.SpeechRequest.TextNormalizat
262254
this.applyTextNormalization = applyTextNormalization;
263255
}
264256

257+
public Boolean getApplyLanguageTextNormalization() {
258+
return this.applyLanguageTextNormalization;
259+
}
260+
261+
public void setApplyLanguageTextNormalization(Boolean applyLanguageTextNormalization) {
262+
this.applyLanguageTextNormalization = applyLanguageTextNormalization;
263+
}
264+
265265
@Override
266266
public boolean equals(Object o) {
267267
if (this == o)
@@ -275,15 +275,16 @@ public boolean equals(Object o) {
275275
&& Objects.equals(seed, that.seed) && Objects.equals(previousText, that.previousText)
276276
&& Objects.equals(nextText, that.nextText)
277277
&& Objects.equals(previousRequestIds, that.previousRequestIds)
278-
&& Objects.equals(nextRequestIds, that.nextRequestIds) && Objects.equals(usePvcAsIvc, that.usePvcAsIvc)
279-
&& Objects.equals(applyTextNormalization, that.applyTextNormalization);
278+
&& Objects.equals(applyTextNormalization, that.applyTextNormalization)
279+
&& Objects.equals(nextRequestIds, that.nextRequestIds)
280+
&& Objects.equals(applyLanguageTextNormalization, that.applyLanguageTextNormalization);
280281
}
281282

282283
@Override
283284
public int hashCode() {
284285
return Objects.hash(modelId, voiceId, outputFormat, voiceSettings, languageCode,
285286
pronunciationDictionaryLocators, seed, previousText, nextText, previousRequestIds, nextRequestIds,
286-
usePvcAsIvc, applyTextNormalization);
287+
applyTextNormalization, applyLanguageTextNormalization);
287288
}
288289

289290
@Override
@@ -292,8 +293,9 @@ public String toString() {
292293
+ ", outputFormat='" + outputFormat + '\'' + ", voiceSettings=" + voiceSettings + ", languageCode='"
293294
+ languageCode + '\'' + ", pronunciationDictionaryLocators=" + pronunciationDictionaryLocators
294295
+ ", seed=" + seed + ", previousText='" + previousText + '\'' + ", nextText='" + nextText + '\''
295-
+ ", previousRequestIds=" + previousRequestIds + ", nextRequestIds=" + nextRequestIds + ", usePvcAsIvc="
296-
+ usePvcAsIvc + ", applyTextNormalization=" + applyTextNormalization + '}';
296+
+ ", previousRequestIds=" + previousRequestIds + ", nextRequestIds=" + nextRequestIds
297+
+ ", applyTextNormalization=" + applyTextNormalization + ", applyLanguageTextNormalization="
298+
+ applyLanguageTextNormalization + '}';
297299
}
298300

299301
@Override
@@ -313,8 +315,8 @@ public ElevenLabsTextToSpeechOptions copy() {
313315
.nextText(this.getNextText())
314316
.previousRequestIds(this.getPreviousRequestIds())
315317
.nextRequestIds(this.getNextRequestIds())
316-
.usePvcAsIvc(this.getUsePvcAsIvc())
317318
.applyTextNormalization(this.getApplyTextNormalization())
319+
.applyLanguageTextNormalization(this.getApplyLanguageTextNormalization())
318320
.build();
319321
}
320322

@@ -388,17 +390,17 @@ public Builder nextRequestIds(List<String> nextRequestIds) {
388390
return this;
389391
}
390392

391-
public Builder usePvcAsIvc(Boolean usePvcAsIvc) {
392-
options.setUsePvcAsIvc(usePvcAsIvc);
393-
return this;
394-
}
395-
396393
public Builder applyTextNormalization(
397394
ElevenLabsApi.SpeechRequest.TextNormalizationMode applyTextNormalization) {
398395
options.setApplyTextNormalization(applyTextNormalization);
399396
return this;
400397
}
401398

399+
public Builder applyLanguageTextNormalization(Boolean applyLanguageTextNormalization) {
400+
options.setApplyLanguageTextNormalization(applyLanguageTextNormalization);
401+
return this;
402+
}
403+
402404
public ElevenLabsTextToSpeechOptions build() {
403405
return this.options;
404406
}

0 commit comments

Comments
 (0)