Skip to content

[Text to Speech] Add newest generated code and update tests #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2018
Merged
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 @@ -43,10 +43,79 @@
import java.io.InputStream;

/**
* The IBM Text to Speech service provides capabilities to synthesize text into natural-sounding speech in a variety of
* ### Service Overview
* The IBM Text to Speech service provides a Representational State Transfer (REST) Application Programming Interface
* (API) that uses IBM's speech-synthesis capabilities to synthesize text into natural-sounding speech in a variety of
* languages, dialects, and voices. The service currently synthesizes text from US English, UK English, French, German,
* Italian, Japanese, Spanish, or Brazilian Portuguese into audio spoken in a male or female voice (the service supports
* only a single gender for some languages). The audio is streamed back to the client with minimal delay.
* ### API Overview
* The Text to Speech service consists of the following related endpoints:
* * `/v1/voices` provides information about the voices available for synthesized speech.
* * `/v1/synthesize` synthesizes written text to audio speech.
* * `/v1/pronunciation` returns the pronunciation for a specified word. The `/v1/pronunciation` method is currently
* beta functionality.
* * `/v1/customizations` and `/v1/customizations/{customization_id}` lets users create custom voice models, which are
* dictionaries of words and their translations for use in speech synthesis. All `/v1/customizations` methods are
* currently beta functionality.
* * `/v1/customizations/{customization_id}/words` and `/v1/customizations/{customization_id}/words/{word}` lets users
* manage the words in a custom voice model.
*
*
* **Note about the Try It Out feature:** The `Try it out!` button lets you experiment with the methods of the API by
* making actual cURL calls to the service. The feature is **not** supported for use with the `POST /v1/synthesize`
* method. For examples of calls to this method, see the [Text to Speech API
* reference](http://www.ibm.com/watson/developercloud/text-to-speech/api/v1/).
* ### API Usage
* The following information provides details about using the service to synthesize audio:
* * **Audio formats:** The service supports a number of audio formats (MIME types). For more information about audio
* formats and sampling rates, including links to a number of Internet sites that provide technical and usage details
* about the different formats, see [Specifying an audio
* format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format).
* * **SSML:** Many methods refer to the Speech Synthesis Markup Language (SSML), an XML-based markup language that
* provides annotations of text for speech-synthesis applications; for example, many methods accept or produce
* translations that use an SSML-based phoneme format. See [Using
* SSML](https://console.bluemix.net/docs/services/text-to-speech/SSML.html) and [Using IBM
* SPR](https://console.bluemix.net/docs/services/text-to-speech/SPRs.html).
* * **Word translations:** Many customization methods accept or return sounds-like or phonetic translations for words.
* A phonetic translation is based on the SSML format for representing the phonetic string of a word. Phonetic
* translations can use standard International Phonetic Alphabet (IPA) representation:
*
* <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme>
*
* or the proprietary IBM Symbolic Phonetic Representation (SPR):
*
* <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme>
*
* For more information about customization and about sounds-like and phonetic translations, see [Understanding
* customization](https://console.bluemix.net/docs/services/text-to-speech/custom-intro.html).
* * **GUIDs:** The pronunciation and customization methods accept or return a Globally Unique Identifier (GUID). For
* example, customization IDs (specified with the `customization_id` parameter) and service credentials are GUIDs. GUIDs
* are hexadecimal strings that have the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
* * **WebSocket interface:** The service also offers a WebSocket interface as an alternative to its HTTP REST interface
* for speech synthesis. The WebSocket interface supports both plain text and SSML input, including the SSML
* <mark> element and word timings. See [The WebSocket
* interface](https://console.bluemix.net/docs/services/text-to-speech/websockets.html).
* * **Authentication:** You authenticate to the service by using your service credentials. You can use your credentials
* to authenticate via a proxy server that resides in IBM Cloud, or you can use your credentials to obtain a token and
* contact the service directly. See [Service credentials for Watson
* services](https://console.bluemix.net/docs/services/watson/getting-started-credentials.html) and [Tokens for
* authentication](https://console.bluemix.net/docs/services/watson/getting-started-tokens.html).
* * **Custom voice model ownership:** In all cases, you must use service credentials created for the instance of the
* service that owns a custom voice model to use the methods described in this documentation with that model. For more
* information, see [Ownership of custom voice
* models](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#customOwner).
* * **Request Logging:** By default, all Watson services log requests and their results. Data is collected only to
* improve the Watson services. If you do not want to share your data, set the header parameter
* `X-Watson-Learning-Opt-Out` to `true` for each request. Data is collected for any request that omits this header. See
* [Controlling request logging for Watson
* services](https://console.bluemix.net/docs/services/watson/getting-started-logging.html).
*
* The service does not log data (words and translations) that are used to build custom language models; your training
* data is never used to improve the service's base models. The service does log data when a custom model is used with a
* synthesize request; you must set the `X-Watson-Learning-Opt-Out` request header to prevent logging for recognition
* requests. For more information, see [Request logging and data
* privacy](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#customLogging).
*
* For more information about the service and its various interfaces, see [About Text to
* Speech](https://console.bluemix.net/docs/services/text-to-speech/index.html).
Expand Down Expand Up @@ -132,13 +201,14 @@ public ServiceCall<Voices> listVoices() {
* Streaming speech synthesis of the text in the body parameter.
*
* Synthesizes text to spoken audio, returning the synthesized audio stream as an array of bytes. Identical to the
* `GET` method but passes longer text in the body of the request, not with the URL. Text size is limited to 5 KB. If
* a request includes invalid query parameters, the service returns a `Warnings` response header that provides
* messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument
* strings. For example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query arguments:\"` followed by
* a list of the form `\"invalid_arg_1, invalid_arg_2.\"` The request succeeds despite the warnings. **Note about the
* Try It Out feature:** The `Try it out!` button is **not** supported for use with the the `POST /v1/synthesize`
* method. For examples of calls to the method, see the [Text to Speech API
* `GET` method but passes longer text in the body of the request, not with the URL. Text size is limited to 5 KB.
* (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or `endianness=little-endian`; the
* default is little endian.) If a request includes invalid query parameters, the service returns a `Warnings`
* response header that provides messages about the invalid parameters. The warning includes a descriptive message and
* a list of invalid argument strings. For example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query
* arguments:\"` followed by a list of the form `\"invalid_arg_1, invalid_arg_2.\"` The request succeeds despite the
* warnings. **Note about the Try It Out feature:** The `Try it out!` button is **not** supported for use with the the
* `POST /v1/synthesize` method. For examples of calls to the method, see the [Text to Speech API
* reference](http://www.ibm.com/watson/developercloud/text-to-speech/api/v1/).
*
* @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call
Expand All @@ -147,9 +217,7 @@ public ServiceCall<Voices> listVoices() {
public ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions) {
Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null");
RequestBuilder builder = RequestBuilder.post("/v1/synthesize");
if (synthesizeOptions.accept() != null) {
builder.header("Accept", synthesizeOptions.accept());
}
builder.header("Accept", synthesizeOptions.accept());
if (synthesizeOptions.voice() != null) {
builder.query("voice", synthesizeOptions.voice());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,4 @@ public class Pronunciation extends GenericModel {
public String getPronunciation() {
return pronunciation;
}

/**
* Sets the pronunciation.
*
* @param pronunciation the new pronunciation
*/
public void setPronunciation(final String pronunciation) {
this.pronunciation = pronunciation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,4 @@ public Boolean isCustomPronunciation() {
public Boolean isVoiceTransformation() {
return voiceTransformation;
}

/**
* Sets the customPronunciation.
*
* @param customPronunciation the new customPronunciation
*/
public void setCustomPronunciation(final Boolean customPronunciation) {
this.customPronunciation = customPronunciation;
}

/**
* Sets the voiceTransformation.
*
* @param voiceTransformation the new voiceTransformation
*/
public void setVoiceTransformation(final Boolean voiceTransformation) {
this.voiceTransformation = voiceTransformation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
public class SynthesizeOptions extends GenericModel {

/**
* The requested audio format (MIME type) of the audio. You can use this header or the `accept` query parameter to
* specify the audio format. (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or
* `endianness=little-endian`; the default is little endian.).
* The type of the response: audio/basic, audio/flac, audio/l16;rate=nnnn, audio/ogg, audio/ogg;codecs=opus,
* audio/ogg;codecs=vorbis, audio/mp3, audio/mpeg, audio/mulaw;rate=nnnn, audio/wav, audio/webm,
* audio/webm;codecs=opus, or audio/webm;codecs=vorbis.
*/
public interface Accept {
/** audio/basic. */
Expand All @@ -48,10 +48,10 @@ public interface Accept {
String AUDIO_WAV = "audio/wav";
/** audio/webm. */
String AUDIO_WEBM = "audio/webm";
/** audio/webm:codecs=opus. */
String AUDIO_WEBM_CODECS_OPUS = "audio/webm:codecs=opus";
/** audio/webm:codecs=vorbis. */
String AUDIO_WEBM_CODECS_VORBIS = "audio/webm:codecs=vorbis";
/** audio/webm;codecs=opus. */
String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus";
/** audio/webm;codecs=vorbis. */
String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis";
}

/**
Expand Down Expand Up @@ -88,25 +88,25 @@ public interface Voice {
String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice";
}

private String text;
private String accept;
private String voice;
private String customizationId;
private String text;

/**
* Builder.
*/
public static class Builder {
private String text;
private String accept;
private String voice;
private String customizationId;
private String text;

private Builder(SynthesizeOptions synthesizeOptions) {
text = synthesizeOptions.text;
accept = synthesizeOptions.accept;
voice = synthesizeOptions.voice;
customizationId = synthesizeOptions.customizationId;
text = synthesizeOptions.text;
}

/**
Expand All @@ -119,9 +119,11 @@ public Builder() {
* Instantiates a new builder with required properties.
*
* @param text the text
* @param accept the accept
*/
public Builder(String text) {
public Builder(String text, String accept) {
this.text = text;
this.accept = accept;
}

/**
Expand All @@ -133,6 +135,17 @@ public SynthesizeOptions build() {
return new SynthesizeOptions(this);
}

/**
* Set the text.
*
* @param text the text
* @return the SynthesizeOptions builder
*/
public Builder text(String text) {
this.text = text;
return this;
}

/**
* Set the accept.
*
Expand Down Expand Up @@ -165,25 +178,15 @@ public Builder customizationId(String customizationId) {
this.customizationId = customizationId;
return this;
}

/**
* Set the text.
*
* @param text the text
* @return the SynthesizeOptions builder
*/
public Builder text(String text) {
this.text = text;
return this;
}
}

private SynthesizeOptions(Builder builder) {
Validator.notNull(builder.text, "text cannot be null");
Validator.notNull(builder.accept, "accept cannot be null");
text = builder.text;
accept = builder.accept;
voice = builder.voice;
customizationId = builder.customizationId;
text = builder.text;
}

/**
Expand All @@ -195,12 +198,23 @@ public Builder newBuilder() {
return new Builder(this);
}

/**
* Gets the text.
*
* The text to synthesize.
*
* @return the text
*/
public String text() {
return text;
}

/**
* Gets the accept.
*
* The requested audio format (MIME type) of the audio. You can use this header or the `accept` query parameter to
* specify the audio format. (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or
* `endianness=little-endian`; the default is little endian.).
* The type of the response: audio/basic, audio/flac, audio/l16;rate=nnnn, audio/ogg, audio/ogg;codecs=opus,
* audio/ogg;codecs=vorbis, audio/mp3, audio/mpeg, audio/mulaw;rate=nnnn, audio/wav, audio/webm,
* audio/webm;codecs=opus, or audio/webm;codecs=vorbis.
*
* @return the accept
*/
Expand Down Expand Up @@ -232,15 +246,4 @@ public String voice() {
public String customizationId() {
return customizationId;
}

/**
* Gets the text.
*
* The text to synthesize.
*
* @return the text
*/
public String text() {
return text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,76 +119,4 @@ public SupportedFeatures getSupportedFeatures() {
public VoiceModel getCustomization() {
return customization;
}

/**
* Sets the url.
*
* @param url the new url
*/
public void setUrl(final String url) {
this.url = url;
}

/**
* Sets the gender.
*
* @param gender the new gender
*/
public void setGender(final String gender) {
this.gender = gender;
}

/**
* Sets the name.
*
* @param name the new name
*/
public void setName(final String name) {
this.name = name;
}

/**
* Sets the language.
*
* @param language the new language
*/
public void setLanguage(final String language) {
this.language = language;
}

/**
* Sets the description.
*
* @param description the new description
*/
public void setDescription(final String description) {
this.description = description;
}

/**
* Sets the customizable.
*
* @param customizable the new customizable
*/
public void setCustomizable(final Boolean customizable) {
this.customizable = customizable;
}

/**
* Sets the supportedFeatures.
*
* @param supportedFeatures the new supportedFeatures
*/
public void setSupportedFeatures(final SupportedFeatures supportedFeatures) {
this.supportedFeatures = supportedFeatures;
}

/**
* Sets the customization.
*
* @param customization the new customization
*/
public void setCustomization(final VoiceModel customization) {
this.customization = customization;
}
}
Loading