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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ You can route TTS through a custom hosting provider like Baseten while keeping t

```java
import resources.texttospeech.requests.CreateStreamTtsRequestPayload;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.TtsLanguage;
import java.io.InputStream;

// Initialize the Baseten Mars8-Flash custom hosting provider.
Expand All @@ -76,7 +76,7 @@ ITtsProvider ttsProvider = new BasetenProvider(
// Use the provider to generate speech
InputStream audioStream = ttsProvider.tts(CreateStreamTtsRequestPayload.builder()
.text("Hello from Java via Baseten Mars8-Flash!")
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.language(TtsLanguage.EN_US)
.voiceId(1) // Required by the SDK's staged builder; ignored by the Baseten provider
.build(), null);
```
Expand All @@ -99,8 +99,8 @@ Convert text into spoken audio using one of Camb AI's high-quality voices.

```java
import resources.texttospeech.requests.CreateStreamTtsRequestPayload;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadSpeechModel;
import resources.texttospeech.types.TtsLanguage;
import resources.texttospeech.types.SpeechModel;
import types.OutputFormat;
import types.StreamTtsOutputConfiguration;
import java.io.InputStream;
Expand All @@ -112,8 +112,8 @@ import java.io.File;
InputStream audioStream = client.textToSpeech().tts(CreateStreamTtsRequestPayload.builder()
.text("Hello from Camb AI! This is a test.")
.voiceId(20303)
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSPRO)
.language(TtsLanguage.EN_US)
.speechModel(SpeechModel.MARSPRO)
.outputConfiguration(StreamTtsOutputConfiguration.builder().format(OutputFormat.WAV).build())
.build());

Expand Down
22 changes: 11 additions & 11 deletions docs/java_sdk_guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Generate and stream speech in real-time. The SDK returns an `InputStream` for th
```java
import core.ClientOptions;
import resources.texttospeech.requests.CreateStreamTtsRequestPayload;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadSpeechModel;
import resources.texttospeech.types.TtsLanguage;
import resources.texttospeech.types.SpeechModel;
import types.Languages;
import java.io.InputStream;
import java.io.FileOutputStream;
Expand All @@ -78,9 +78,9 @@ public class BasicTts {
try {
InputStream audioStream = client.textToSpeech().tts(CreateStreamTtsRequestPayload.builder()
.text("Hello from Camb AI! This is a demonstration of our advanced text-to-speech technology using the MARS Pro model.")
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.language(TtsLanguage.EN_US)
.voiceId(20303)
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSPRO)
.speechModel(SpeechModel.MARSPRO)
.outputConfiguration(StreamTtsOutputConfiguration.builder().format(OutputFormat.WAV).build())
.build());

Expand Down Expand Up @@ -128,17 +128,17 @@ Camb.ai offers three MARS models optimized for different use cases:

<CodeGroup>
```java MARS Flash
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSFLASH)
.speechModel(SpeechModel.MARSFLASH)
// Best for: Real-time voice agents, low-latency applications
// Sample rate: 22.05kHz
```
```java MARS Pro
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSPRO)
.speechModel(SpeechModel.MARSPRO)
// Best for: Audio production, high-quality content
// Sample rate: 48kHz
```
```java MARS Instruct
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSINSTRUCT)
.speechModel(SpeechModel.MARSINSTRUCT)
.userInstructions("Speak in a warm, friendly tone")
// Best for: Fine-grained control over tone and style
// Sample rate: 22.05kHz
Expand All @@ -163,18 +163,18 @@ for (var voice : voices) {

## Language Support

Camb.ai supports 140+ languages. Specify the language using the `CreateStreamTtsRequestPayloadLanguage` enum:
Camb.ai supports 140+ languages. Specify the language using the `TtsLanguage` enum:
Languages supported by each model mentioned at [MARS Models](https://docs.camb.ai/models).

```java
// English (US)
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.language(TtsLanguage.EN_US)

// Spanish
.language(CreateStreamTtsRequestPayloadLanguage.ES_ES)
.language(TtsLanguage.ES_ES)

// French
.language(CreateStreamTtsRequestPayloadLanguage.FR_FR)
.language(TtsLanguage.FR_FR)
```

---
Expand Down
4 changes: 2 additions & 2 deletions examples/BasetenExample.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import resources.texttospeech.requests.CreateStreamTtsRequestPayload;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.TtsLanguage;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.File;
Expand Down Expand Up @@ -60,7 +60,7 @@ public static void main(String[] args) {
// when routing through a custom hosting provider.
CreateStreamTtsRequestPayload request = CreateStreamTtsRequestPayload.builder()
.text("Hello. This is speech generated via a Baseten Mars8-Flash custom hosting provider.")
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.language(TtsLanguage.EN_US)
.voiceId(1) // Required by the SDK's staged builder; ignored by the Baseten provider
.build();

Expand Down
8 changes: 4 additions & 4 deletions examples/BasicTts.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import core.ClientOptions;
import resources.texttospeech.requests.CreateStreamTtsRequestPayload;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadSpeechModel;
import resources.texttospeech.types.TtsLanguage;
import resources.texttospeech.types.SpeechModel;
import types.Languages;
import java.io.InputStream;
import java.io.FileOutputStream;
Expand All @@ -28,9 +28,9 @@ public static void main(String[] args) {
// Model: MARSPRO, Format: WAV
InputStream audioStream = client.textToSpeech().tts(CreateStreamTtsRequestPayload.builder()
.text("Hello from Camb AI! This is a demonstration of our advanced text-to-speech technology using the MARS Pro model.")
.language(CreateStreamTtsRequestPayloadLanguage.EN_US)
.language(TtsLanguage.EN_US)
.voiceId(20303)
.speechModel(CreateStreamTtsRequestPayloadSpeechModel.MARSPRO)
.speechModel(SpeechModel.MARSPRO)
.outputConfiguration(StreamTtsOutputConfiguration.builder().format(OutputFormat.WAV).build())
.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Objects;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadLanguage;
import resources.texttospeech.types.CreateStreamTtsRequestPayloadSpeechModel;
import resources.texttospeech.types.TtsLanguage;
import resources.texttospeech.types.SpeechModel;
import types.StreamTtsInferenceOptions;
import types.StreamTtsOutputConfiguration;
import types.StreamTtsVoiceSettings;
Expand All @@ -34,11 +34,11 @@
public final class CreateStreamTtsRequestPayload {
private final String text;

private final CreateStreamTtsRequestPayloadLanguage language;
private final TtsLanguage language;

private final int voiceId;

private final Optional<CreateStreamTtsRequestPayloadSpeechModel> speechModel;
private final Optional<SpeechModel> speechModel;

private final Optional<String> userInstructions;

Expand All @@ -52,8 +52,8 @@ public final class CreateStreamTtsRequestPayload {

private final Map<String, Object> additionalProperties;

private CreateStreamTtsRequestPayload(String text, CreateStreamTtsRequestPayloadLanguage language,
int voiceId, Optional<CreateStreamTtsRequestPayloadSpeechModel> speechModel,
private CreateStreamTtsRequestPayload(String text, TtsLanguage language,
int voiceId, Optional<SpeechModel> speechModel,
Optional<String> userInstructions, Optional<Boolean> enhanceNamedEntitiesPronunciation,
Optional<StreamTtsOutputConfiguration> outputConfiguration,
Optional<StreamTtsVoiceSettings> voiceSettings,
Expand All @@ -77,7 +77,7 @@ public String getText() {
}

@JsonProperty("language")
public CreateStreamTtsRequestPayloadLanguage getLanguage() {
public TtsLanguage getLanguage() {
return language;
}

Expand All @@ -87,7 +87,7 @@ public int getVoiceId() {
}

@JsonProperty("speech_model")
public Optional<CreateStreamTtsRequestPayloadSpeechModel> getSpeechModel() {
public Optional<SpeechModel> getSpeechModel() {
return speechModel;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public interface TextStage {
}

public interface LanguageStage {
VoiceIdStage language(@NotNull CreateStreamTtsRequestPayloadLanguage language);
VoiceIdStage language(@NotNull TtsLanguage language);
}

public interface VoiceIdStage {
Expand All @@ -162,9 +162,9 @@ public interface VoiceIdStage {
public interface _FinalStage {
CreateStreamTtsRequestPayload build();

_FinalStage speechModel(Optional<CreateStreamTtsRequestPayloadSpeechModel> speechModel);
_FinalStage speechModel(Optional<SpeechModel> speechModel);

_FinalStage speechModel(CreateStreamTtsRequestPayloadSpeechModel speechModel);
_FinalStage speechModel(SpeechModel speechModel);

_FinalStage userInstructions(Optional<String> userInstructions);

Expand Down Expand Up @@ -194,7 +194,7 @@ _FinalStage enhanceNamedEntitiesPronunciation(
public static final class Builder implements TextStage, LanguageStage, VoiceIdStage, _FinalStage {
private String text;

private CreateStreamTtsRequestPayloadLanguage language;
private TtsLanguage language;

private int voiceId;

Expand All @@ -208,7 +208,7 @@ public static final class Builder implements TextStage, LanguageStage, VoiceIdSt

private Optional<String> userInstructions = Optional.empty();

private Optional<CreateStreamTtsRequestPayloadSpeechModel> speechModel = Optional.empty();
private Optional<SpeechModel> speechModel = Optional.empty();

@JsonAnySetter
private Map<String, Object> additionalProperties = new HashMap<>();
Expand Down Expand Up @@ -239,7 +239,7 @@ public LanguageStage text(@NotNull String text) {

@java.lang.Override
@JsonSetter("language")
public VoiceIdStage language(@NotNull CreateStreamTtsRequestPayloadLanguage language) {
public VoiceIdStage language(@NotNull TtsLanguage language) {
this.language = Objects.requireNonNull(language, "language must not be null");
return this;
}
Expand Down Expand Up @@ -335,7 +335,7 @@ public _FinalStage userInstructions(Optional<String> userInstructions) {
}

@java.lang.Override
public _FinalStage speechModel(CreateStreamTtsRequestPayloadSpeechModel speechModel) {
public _FinalStage speechModel(SpeechModel speechModel) {
this.speechModel = Optional.ofNullable(speechModel);
return this;
}
Expand All @@ -345,7 +345,7 @@ public _FinalStage speechModel(CreateStreamTtsRequestPayloadSpeechModel speechMo
value = "speech_model",
nulls = Nulls.SKIP
)
public _FinalStage speechModel(Optional<CreateStreamTtsRequestPayloadSpeechModel> speechModel) {
public _FinalStage speechModel(Optional<SpeechModel> speechModel) {
this.speechModel = speechModel;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fasterxml.jackson.annotation.JsonValue;
import java.lang.String;

public enum CreateStreamTtsRequestPayloadSpeechModel {
public enum SpeechModel {
AUTO("auto"),

MARS8("mars-8"),
Expand All @@ -24,11 +24,17 @@ public enum CreateStreamTtsRequestPayloadSpeechModel {

MARSFLASH("mars-flash"),

MARSINSTRUCT("mars-instruct");
MARSINSTRUCT("mars-instruct"),

MARS_PRO("mars-pro"),

MARS_FLASH("mars-flash"),

MARS_INSTRUCT("mars-instruct");

private final String value;

CreateStreamTtsRequestPayloadSpeechModel(String value) {
SpeechModel(String value) {
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fasterxml.jackson.annotation.JsonValue;
import java.lang.String;

public enum CreateStreamTtsRequestPayloadLanguage {
public enum TtsLanguage {
AR_KW("ar-kw"),

DE_CH("de-ch"),
Expand Down Expand Up @@ -134,7 +134,7 @@ public enum CreateStreamTtsRequestPayloadLanguage {

private final String value;

CreateStreamTtsRequestPayloadLanguage(String value) {
TtsLanguage(String value) {
this.value = value;
}

Expand Down
Loading