Skip to content

Commit bff9b76

Browse files
Merge pull request #884 from watson-developer-cloud/codegen/text-to-speech
[Text to Speech] Add newest generated code and update tests
2 parents 2553b52 + fb99335 commit bff9b76

File tree

20 files changed

+292
-431
lines changed

20 files changed

+292
-431
lines changed

text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,79 @@
4343
import java.io.InputStream;
4444

4545
/**
46-
* The IBM Text to Speech service provides capabilities to synthesize text into natural-sounding speech in a variety of
46+
* ### Service Overview
47+
* The IBM Text to Speech service provides a Representational State Transfer (REST) Application Programming Interface
48+
* (API) that uses IBM's speech-synthesis capabilities to synthesize text into natural-sounding speech in a variety of
4749
* languages, dialects, and voices. The service currently synthesizes text from US English, UK English, French, German,
4850
* Italian, Japanese, Spanish, or Brazilian Portuguese into audio spoken in a male or female voice (the service supports
4951
* only a single gender for some languages). The audio is streamed back to the client with minimal delay.
52+
* ### API Overview
53+
* The Text to Speech service consists of the following related endpoints:
54+
* * `/v1/voices` provides information about the voices available for synthesized speech.
55+
* * `/v1/synthesize` synthesizes written text to audio speech.
56+
* * `/v1/pronunciation` returns the pronunciation for a specified word. The `/v1/pronunciation` method is currently
57+
* beta functionality.
58+
* * `/v1/customizations` and `/v1/customizations/{customization_id}` lets users create custom voice models, which are
59+
* dictionaries of words and their translations for use in speech synthesis. All `/v1/customizations` methods are
60+
* currently beta functionality.
61+
* * `/v1/customizations/{customization_id}/words` and `/v1/customizations/{customization_id}/words/{word}` lets users
62+
* manage the words in a custom voice model.
63+
*
64+
*
65+
* **Note about the Try It Out feature:** The `Try it out!` button lets you experiment with the methods of the API by
66+
* making actual cURL calls to the service. The feature is **not** supported for use with the `POST /v1/synthesize`
67+
* method. For examples of calls to this method, see the [Text to Speech API
68+
* reference](http://www.ibm.com/watson/developercloud/text-to-speech/api/v1/).
69+
* ### API Usage
70+
* The following information provides details about using the service to synthesize audio:
71+
* * **Audio formats:** The service supports a number of audio formats (MIME types). For more information about audio
72+
* formats and sampling rates, including links to a number of Internet sites that provide technical and usage details
73+
* about the different formats, see [Specifying an audio
74+
* format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format).
75+
* * **SSML:** Many methods refer to the Speech Synthesis Markup Language (SSML), an XML-based markup language that
76+
* provides annotations of text for speech-synthesis applications; for example, many methods accept or produce
77+
* translations that use an SSML-based phoneme format. See [Using
78+
* SSML](https://console.bluemix.net/docs/services/text-to-speech/SSML.html) and [Using IBM
79+
* SPR](https://console.bluemix.net/docs/services/text-to-speech/SPRs.html).
80+
* * **Word translations:** Many customization methods accept or return sounds-like or phonetic translations for words.
81+
* A phonetic translation is based on the SSML format for representing the phonetic string of a word. Phonetic
82+
* translations can use standard International Phonetic Alphabet (IPA) representation:
83+
*
84+
* <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme>
85+
*
86+
* or the proprietary IBM Symbolic Phonetic Representation (SPR):
87+
*
88+
* <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme>
89+
*
90+
* For more information about customization and about sounds-like and phonetic translations, see [Understanding
91+
* customization](https://console.bluemix.net/docs/services/text-to-speech/custom-intro.html).
92+
* * **GUIDs:** The pronunciation and customization methods accept or return a Globally Unique Identifier (GUID). For
93+
* example, customization IDs (specified with the `customization_id` parameter) and service credentials are GUIDs. GUIDs
94+
* are hexadecimal strings that have the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
95+
* * **WebSocket interface:** The service also offers a WebSocket interface as an alternative to its HTTP REST interface
96+
* for speech synthesis. The WebSocket interface supports both plain text and SSML input, including the SSML
97+
* <mark> element and word timings. See [The WebSocket
98+
* interface](https://console.bluemix.net/docs/services/text-to-speech/websockets.html).
99+
* * **Authentication:** You authenticate to the service by using your service credentials. You can use your credentials
100+
* to authenticate via a proxy server that resides in IBM Cloud, or you can use your credentials to obtain a token and
101+
* contact the service directly. See [Service credentials for Watson
102+
* services](https://console.bluemix.net/docs/services/watson/getting-started-credentials.html) and [Tokens for
103+
* authentication](https://console.bluemix.net/docs/services/watson/getting-started-tokens.html).
104+
* * **Custom voice model ownership:** In all cases, you must use service credentials created for the instance of the
105+
* service that owns a custom voice model to use the methods described in this documentation with that model. For more
106+
* information, see [Ownership of custom voice
107+
* models](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#customOwner).
108+
* * **Request Logging:** By default, all Watson services log requests and their results. Data is collected only to
109+
* improve the Watson services. If you do not want to share your data, set the header parameter
110+
* `X-Watson-Learning-Opt-Out` to `true` for each request. Data is collected for any request that omits this header. See
111+
* [Controlling request logging for Watson
112+
* services](https://console.bluemix.net/docs/services/watson/getting-started-logging.html).
113+
*
114+
* The service does not log data (words and translations) that are used to build custom language models; your training
115+
* data is never used to improve the service's base models. The service does log data when a custom model is used with a
116+
* synthesize request; you must set the `X-Watson-Learning-Opt-Out` request header to prevent logging for recognition
117+
* requests. For more information, see [Request logging and data
118+
* privacy](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#customLogging).
50119
*
51120
* For more information about the service and its various interfaces, see [About Text to
52121
* Speech](https://console.bluemix.net/docs/services/text-to-speech/index.html).
@@ -132,13 +201,14 @@ public ServiceCall<Voices> listVoices() {
132201
* Streaming speech synthesis of the text in the body parameter.
133202
*
134203
* Synthesizes text to spoken audio, returning the synthesized audio stream as an array of bytes. Identical to the
135-
* `GET` method but passes longer text in the body of the request, not with the URL. Text size is limited to 5 KB. If
136-
* a request includes invalid query parameters, the service returns a `Warnings` response header that provides
137-
* messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument
138-
* strings. For example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query arguments:\"` followed by
139-
* a list of the form `\"invalid_arg_1, invalid_arg_2.\"` The request succeeds despite the warnings. **Note about the
140-
* Try It Out feature:** The `Try it out!` button is **not** supported for use with the the `POST /v1/synthesize`
141-
* method. For examples of calls to the method, see the [Text to Speech API
204+
* `GET` method but passes longer text in the body of the request, not with the URL. Text size is limited to 5 KB.
205+
* (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or `endianness=little-endian`; the
206+
* default is little endian.) If a request includes invalid query parameters, the service returns a `Warnings`
207+
* response header that provides messages about the invalid parameters. The warning includes a descriptive message and
208+
* a list of invalid argument strings. For example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query
209+
* arguments:\"` followed by a list of the form `\"invalid_arg_1, invalid_arg_2.\"` The request succeeds despite the
210+
* warnings. **Note about the Try It Out feature:** The `Try it out!` button is **not** supported for use with the the
211+
* `POST /v1/synthesize` method. For examples of calls to the method, see the [Text to Speech API
142212
* reference](http://www.ibm.com/watson/developercloud/text-to-speech/api/v1/).
143213
*
144214
* @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call
@@ -147,9 +217,7 @@ public ServiceCall<Voices> listVoices() {
147217
public ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions) {
148218
Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null");
149219
RequestBuilder builder = RequestBuilder.post("/v1/synthesize");
150-
if (synthesizeOptions.accept() != null) {
151-
builder.header("Accept", synthesizeOptions.accept());
152-
}
220+
builder.header("Accept", synthesizeOptions.accept());
153221
if (synthesizeOptions.voice() != null) {
154222
builder.query("voice", synthesizeOptions.voice());
155223
}

text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Pronunciation.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,4 @@ public class Pronunciation extends GenericModel {
3131
public String getPronunciation() {
3232
return pronunciation;
3333
}
34-
35-
/**
36-
* Sets the pronunciation.
37-
*
38-
* @param pronunciation the new pronunciation
39-
*/
40-
public void setPronunciation(final String pronunciation) {
41-
this.pronunciation = pronunciation;
42-
}
4334
}

text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SupportedFeatures.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,4 @@ public Boolean isCustomPronunciation() {
4747
public Boolean isVoiceTransformation() {
4848
return voiceTransformation;
4949
}
50-
51-
/**
52-
* Sets the customPronunciation.
53-
*
54-
* @param customPronunciation the new customPronunciation
55-
*/
56-
public void setCustomPronunciation(final Boolean customPronunciation) {
57-
this.customPronunciation = customPronunciation;
58-
}
59-
60-
/**
61-
* Sets the voiceTransformation.
62-
*
63-
* @param voiceTransformation the new voiceTransformation
64-
*/
65-
public void setVoiceTransformation(final Boolean voiceTransformation) {
66-
this.voiceTransformation = voiceTransformation;
67-
}
6850
}

text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SynthesizeOptions.java

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
public class SynthesizeOptions extends GenericModel {
2222

2323
/**
24-
* The requested audio format (MIME type) of the audio. You can use this header or the `accept` query parameter to
25-
* specify the audio format. (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or
26-
* `endianness=little-endian`; the default is little endian.).
24+
* The type of the response: audio/basic, audio/flac, audio/l16;rate=nnnn, audio/ogg, audio/ogg;codecs=opus,
25+
* audio/ogg;codecs=vorbis, audio/mp3, audio/mpeg, audio/mulaw;rate=nnnn, audio/wav, audio/webm,
26+
* audio/webm;codecs=opus, or audio/webm;codecs=vorbis.
2727
*/
2828
public interface Accept {
2929
/** audio/basic. */
@@ -48,10 +48,10 @@ public interface Accept {
4848
String AUDIO_WAV = "audio/wav";
4949
/** audio/webm. */
5050
String AUDIO_WEBM = "audio/webm";
51-
/** audio/webm:codecs=opus. */
52-
String AUDIO_WEBM_CODECS_OPUS = "audio/webm:codecs=opus";
53-
/** audio/webm:codecs=vorbis. */
54-
String AUDIO_WEBM_CODECS_VORBIS = "audio/webm:codecs=vorbis";
51+
/** audio/webm;codecs=opus. */
52+
String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus";
53+
/** audio/webm;codecs=vorbis. */
54+
String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis";
5555
}
5656

5757
/**
@@ -88,25 +88,25 @@ public interface Voice {
8888
String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice";
8989
}
9090

91+
private String text;
9192
private String accept;
9293
private String voice;
9394
private String customizationId;
94-
private String text;
9595

9696
/**
9797
* Builder.
9898
*/
9999
public static class Builder {
100+
private String text;
100101
private String accept;
101102
private String voice;
102103
private String customizationId;
103-
private String text;
104104

105105
private Builder(SynthesizeOptions synthesizeOptions) {
106+
text = synthesizeOptions.text;
106107
accept = synthesizeOptions.accept;
107108
voice = synthesizeOptions.voice;
108109
customizationId = synthesizeOptions.customizationId;
109-
text = synthesizeOptions.text;
110110
}
111111

112112
/**
@@ -119,9 +119,11 @@ public Builder() {
119119
* Instantiates a new builder with required properties.
120120
*
121121
* @param text the text
122+
* @param accept the accept
122123
*/
123-
public Builder(String text) {
124+
public Builder(String text, String accept) {
124125
this.text = text;
126+
this.accept = accept;
125127
}
126128

127129
/**
@@ -133,6 +135,17 @@ public SynthesizeOptions build() {
133135
return new SynthesizeOptions(this);
134136
}
135137

138+
/**
139+
* Set the text.
140+
*
141+
* @param text the text
142+
* @return the SynthesizeOptions builder
143+
*/
144+
public Builder text(String text) {
145+
this.text = text;
146+
return this;
147+
}
148+
136149
/**
137150
* Set the accept.
138151
*
@@ -165,25 +178,15 @@ public Builder customizationId(String customizationId) {
165178
this.customizationId = customizationId;
166179
return this;
167180
}
168-
169-
/**
170-
* Set the text.
171-
*
172-
* @param text the text
173-
* @return the SynthesizeOptions builder
174-
*/
175-
public Builder text(String text) {
176-
this.text = text;
177-
return this;
178-
}
179181
}
180182

181183
private SynthesizeOptions(Builder builder) {
182184
Validator.notNull(builder.text, "text cannot be null");
185+
Validator.notNull(builder.accept, "accept cannot be null");
186+
text = builder.text;
183187
accept = builder.accept;
184188
voice = builder.voice;
185189
customizationId = builder.customizationId;
186-
text = builder.text;
187190
}
188191

189192
/**
@@ -195,12 +198,23 @@ public Builder newBuilder() {
195198
return new Builder(this);
196199
}
197200

201+
/**
202+
* Gets the text.
203+
*
204+
* The text to synthesize.
205+
*
206+
* @return the text
207+
*/
208+
public String text() {
209+
return text;
210+
}
211+
198212
/**
199213
* Gets the accept.
200214
*
201-
* The requested audio format (MIME type) of the audio. You can use this header or the `accept` query parameter to
202-
* specify the audio format. (For the `audio/l16` format, you can optionally specify `endianness=big-endian` or
203-
* `endianness=little-endian`; the default is little endian.).
215+
* The type of the response: audio/basic, audio/flac, audio/l16;rate=nnnn, audio/ogg, audio/ogg;codecs=opus,
216+
* audio/ogg;codecs=vorbis, audio/mp3, audio/mpeg, audio/mulaw;rate=nnnn, audio/wav, audio/webm,
217+
* audio/webm;codecs=opus, or audio/webm;codecs=vorbis.
204218
*
205219
* @return the accept
206220
*/
@@ -232,15 +246,4 @@ public String voice() {
232246
public String customizationId() {
233247
return customizationId;
234248
}
235-
236-
/**
237-
* Gets the text.
238-
*
239-
* The text to synthesize.
240-
*
241-
* @return the text
242-
*/
243-
public String text() {
244-
return text;
245-
}
246249
}

text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Voice.java

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -119,76 +119,4 @@ public SupportedFeatures getSupportedFeatures() {
119119
public VoiceModel getCustomization() {
120120
return customization;
121121
}
122-
123-
/**
124-
* Sets the url.
125-
*
126-
* @param url the new url
127-
*/
128-
public void setUrl(final String url) {
129-
this.url = url;
130-
}
131-
132-
/**
133-
* Sets the gender.
134-
*
135-
* @param gender the new gender
136-
*/
137-
public void setGender(final String gender) {
138-
this.gender = gender;
139-
}
140-
141-
/**
142-
* Sets the name.
143-
*
144-
* @param name the new name
145-
*/
146-
public void setName(final String name) {
147-
this.name = name;
148-
}
149-
150-
/**
151-
* Sets the language.
152-
*
153-
* @param language the new language
154-
*/
155-
public void setLanguage(final String language) {
156-
this.language = language;
157-
}
158-
159-
/**
160-
* Sets the description.
161-
*
162-
* @param description the new description
163-
*/
164-
public void setDescription(final String description) {
165-
this.description = description;
166-
}
167-
168-
/**
169-
* Sets the customizable.
170-
*
171-
* @param customizable the new customizable
172-
*/
173-
public void setCustomizable(final Boolean customizable) {
174-
this.customizable = customizable;
175-
}
176-
177-
/**
178-
* Sets the supportedFeatures.
179-
*
180-
* @param supportedFeatures the new supportedFeatures
181-
*/
182-
public void setSupportedFeatures(final SupportedFeatures supportedFeatures) {
183-
this.supportedFeatures = supportedFeatures;
184-
}
185-
186-
/**
187-
* Sets the customization.
188-
*
189-
* @param customization the new customization
190-
*/
191-
public void setCustomization(final VoiceModel customization) {
192-
this.customization = customization;
193-
}
194122
}

0 commit comments

Comments
 (0)