Class SpeechCreateParams.Voice
-
- All Implemented Interfaces:
public final class SpeechCreateParams.VoiceThe voice to use when generating the audio. Supported built-in voices are
alloy,ash,ballad,coral,echo,fable,onyx,nova,sage,shimmer,verse,marin, andcedar. You may also provide a custom voice object with anid, for example{ "id": "voice_1234" }. Previews of the voices are available in the Text to speech guide.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceSpeechCreateParams.Voice.VisitorAn interface that defines how to map each variant of Voice to a value of type T.
public final classSpeechCreateParams.Voice.UnionMember1public final classSpeechCreateParams.Voice.IdCustom voice reference.
-
Method Summary
-
-
Method Detail
-
unionMember1
final Optional<SpeechCreateParams.Voice.UnionMember1> unionMember1()
-
id
final Optional<SpeechCreateParams.Voice.Id> id()
Custom voice reference.
-
isUnionMember1
final Boolean isUnionMember1()
-
asUnionMember1
final SpeechCreateParams.Voice.UnionMember1 asUnionMember1()
-
asId
final SpeechCreateParams.Voice.Id asId()
Custom voice reference.
-
accept
final <T extends Any> T accept(SpeechCreateParams.Voice.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = voice.accept(new Voice.Visitor<Optional<String>>() { @Override public Optional<String> visitString(String string) { return Optional.of(string.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final SpeechCreateParams.Voice validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofString
final static SpeechCreateParams.Voice ofString(String string)
-
ofUnionMember1
final static SpeechCreateParams.Voice ofUnionMember1(SpeechCreateParams.Voice.UnionMember1 unionMember1)
-
ofId
final static SpeechCreateParams.Voice ofId(SpeechCreateParams.Voice.Id id)
Custom voice reference.
-
-
-
-