|
43 | 43 | import java.io.InputStream;
|
44 | 44 |
|
45 | 45 | /**
|
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 |
49 |
| - * languages, dialects, and voices. The service currently synthesizes text from US English, UK English, French, German, |
50 |
| - * Italian, Japanese, Spanish, or Brazilian Portuguese into audio spoken in a male or female voice (the service supports |
51 |
| - * only a single gender for some languages). The audio is streamed back to the client with minimal delay. |
52 |
| - * ### API Overview |
53 | 46 | * The Text to Speech service consists of the following related endpoints:
|
54 | 47 | * * `/v1/voices` provides information about the voices available for synthesized speech.
|
55 | 48 | * * `/v1/synthesize` synthesizes written text to audio speech.
|
|
61 | 54 | * * `/v1/customizations/{customization_id}/words` and `/v1/customizations/{customization_id}/words/{word}` lets users
|
62 | 55 | * manage the words in a custom voice model.
|
63 | 56 | *
|
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). |
119 |
| - * |
120 | 57 | * For more information about the service and its various interfaces, see [About Text to
|
121 | 58 | * Speech](https://console.bluemix.net/docs/services/text-to-speech/index.html).
|
122 | 59 | *
|
@@ -217,7 +154,9 @@ public ServiceCall<Voices> listVoices() {
|
217 | 154 | public ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions) {
|
218 | 155 | Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null");
|
219 | 156 | RequestBuilder builder = RequestBuilder.post("/v1/synthesize");
|
220 |
| - builder.header("Accept", synthesizeOptions.accept()); |
| 157 | + if (synthesizeOptions.accept() != null) { |
| 158 | + builder.header("Accept", synthesizeOptions.accept()); |
| 159 | + } |
221 | 160 | if (synthesizeOptions.voice() != null) {
|
222 | 161 | builder.query("voice", synthesizeOptions.voice());
|
223 | 162 | }
|
|
0 commit comments