cloud_tts.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // Copyright 2019 Google LLC.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. syntax = "proto3";
  16. package google.cloud.texttospeech.v1;
  17. import "google/api/annotations.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. option cc_enable_arenas = true;
  21. option csharp_namespace = "Google.Cloud.TextToSpeech.V1";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/texttospeech/v1;texttospeech";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "TextToSpeechProto";
  25. option java_package = "com.google.cloud.texttospeech.v1";
  26. option php_namespace = "Google\\Cloud\\TextToSpeech\\V1";
  27. option ruby_package = "Google::Cloud::TextToSpeech::V1";
  28. // Service that implements Google Cloud Text-to-Speech API.
  29. service TextToSpeech {
  30. option (google.api.default_host) = "texttospeech.googleapis.com";
  31. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  32. // Returns a list of Voice supported for synthesis.
  33. rpc ListVoices(ListVoicesRequest) returns (ListVoicesResponse) {
  34. option (google.api.http) = {
  35. get: "/v1/voices"
  36. };
  37. option (google.api.method_signature) = "language_code";
  38. }
  39. // Synthesizes speech synchronously: receive results after all text input
  40. // has been processed.
  41. rpc SynthesizeSpeech(SynthesizeSpeechRequest) returns (SynthesizeSpeechResponse) {
  42. option (google.api.http) = {
  43. post: "/v1/text:synthesize"
  44. body: "*"
  45. };
  46. option (google.api.method_signature) = "input,voice,audio_config";
  47. }
  48. }
  49. // The top-level message sent by the client for the `ListVoices` method.
  50. message ListVoicesRequest {
  51. // Optional. Recommended.
  52. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If
  53. // specified, the ListVoices call will only return voices that can be used to
  54. // synthesize this language_code. E.g. when specifying "en-NZ", you will get
  55. // supported "en-\*" voices; when specifying "no", you will get supported
  56. // "no-\*" (Norwegian) and "nb-\*" (Norwegian Bokmal) voices; specifying "zh"
  57. // will also get supported "cmn-\*" voices; specifying "zh-hk" will also get
  58. // supported "yue-\*" voices.
  59. string language_code = 1 [(google.api.field_behavior) = OPTIONAL];
  60. }
  61. // Gender of the voice as described in
  62. // [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
  63. enum SsmlVoiceGender {
  64. // An unspecified gender.
  65. // In VoiceSelectionParams, this means that the client doesn't care which
  66. // gender the selected voice will have. In the Voice field of
  67. // ListVoicesResponse, this may mean that the voice doesn't fit any of the
  68. // other categories in this enum, or that the gender of the voice isn't known.
  69. SSML_VOICE_GENDER_UNSPECIFIED = 0;
  70. // A male voice.
  71. MALE = 1;
  72. // A female voice.
  73. FEMALE = 2;
  74. // A gender-neutral voice.
  75. NEUTRAL = 3;
  76. }
  77. // Configuration to set up audio encoder. The encoding determines the output
  78. // audio format that we'd like.
  79. enum AudioEncoding {
  80. // Not specified. Will return result [google.rpc.Code.INVALID_ARGUMENT][].
  81. AUDIO_ENCODING_UNSPECIFIED = 0;
  82. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  83. // Audio content returned as LINEAR16 also contains a WAV header.
  84. LINEAR16 = 1;
  85. // MP3 audio at 32kbps.
  86. MP3 = 2;
  87. // Opus encoded audio wrapped in an ogg container. The result will be a
  88. // file which can be played natively on Android, and in browsers (at least
  89. // Chrome and Firefox). The quality of the encoding is considerably higher
  90. // than MP3 while using approximately the same bitrate.
  91. OGG_OPUS = 3;
  92. }
  93. // The message returned to the client by the `ListVoices` method.
  94. message ListVoicesResponse {
  95. // The list of voices.
  96. repeated Voice voices = 1;
  97. }
  98. // Description of a voice supported by the TTS service.
  99. message Voice {
  100. // The languages that this voice supports, expressed as
  101. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g.
  102. // "en-US", "es-419", "cmn-tw").
  103. repeated string language_codes = 1;
  104. // The name of this voice. Each distinct voice has a unique name.
  105. string name = 2;
  106. // The gender of this voice.
  107. SsmlVoiceGender ssml_gender = 3;
  108. // The natural sample rate (in hertz) for this voice.
  109. int32 natural_sample_rate_hertz = 4;
  110. }
  111. // The top-level message sent by the client for the `SynthesizeSpeech` method.
  112. message SynthesizeSpeechRequest {
  113. // Required. The Synthesizer requires either plain text or SSML as input.
  114. SynthesisInput input = 1 [(google.api.field_behavior) = REQUIRED];
  115. // Required. The desired voice of the synthesized audio.
  116. VoiceSelectionParams voice = 2 [(google.api.field_behavior) = REQUIRED];
  117. // Required. The configuration of the synthesized audio.
  118. AudioConfig audio_config = 3 [(google.api.field_behavior) = REQUIRED];
  119. }
  120. // Contains text input to be synthesized. Either `text` or `ssml` must be
  121. // supplied. Supplying both or neither returns
  122. // [google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to 5000
  123. // characters.
  124. message SynthesisInput {
  125. // The input source, which is either plain text or SSML.
  126. oneof input_source {
  127. // The raw text to be synthesized.
  128. string text = 1;
  129. // The SSML document to be synthesized. The SSML document must be valid
  130. // and well-formed. Otherwise the RPC will fail and return
  131. // [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
  132. // [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
  133. string ssml = 2;
  134. }
  135. }
  136. // Description of which voice to use for a synthesis request.
  137. message VoiceSelectionParams {
  138. // Required. The language (and potentially also the region) of the voice expressed as a
  139. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g.
  140. // "en-US". This should not include a script tag (e.g. use
  141. // "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
  142. // from the input provided in the SynthesisInput. The TTS service
  143. // will use this parameter to help choose an appropriate voice. Note that
  144. // the TTS service may choose a voice with a slightly different language code
  145. // than the one selected; it may substitute a different region
  146. // (e.g. using en-US rather than en-CA if there isn't a Canadian voice
  147. // available), or even a different language, e.g. using "nb" (Norwegian
  148. // Bokmal) instead of "no" (Norwegian)".
  149. string language_code = 1 [(google.api.field_behavior) = REQUIRED];
  150. // The name of the voice. If not set, the service will choose a
  151. // voice based on the other parameters such as language_code and gender.
  152. string name = 2;
  153. // The preferred gender of the voice. If not set, the service will
  154. // choose a voice based on the other parameters such as language_code and
  155. // name. Note that this is only a preference, not requirement; if a
  156. // voice of the appropriate gender is not available, the synthesizer should
  157. // substitute a voice with a different gender rather than failing the request.
  158. SsmlVoiceGender ssml_gender = 3;
  159. }
  160. // Description of audio data to be synthesized.
  161. message AudioConfig {
  162. // Required. The format of the audio byte stream.
  163. AudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  164. // Optional. Input only. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is
  165. // the normal native speed supported by the specific voice. 2.0 is twice as
  166. // fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0
  167. // speed. Any other values < 0.25 or > 4.0 will return an error.
  168. double speaking_rate = 2 [
  169. (google.api.field_behavior) = INPUT_ONLY,
  170. (google.api.field_behavior) = OPTIONAL
  171. ];
  172. // Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
  173. // increase 20 semitones from the original pitch. -20 means decrease 20
  174. // semitones from the original pitch.
  175. double pitch = 3 [
  176. (google.api.field_behavior) = INPUT_ONLY,
  177. (google.api.field_behavior) = OPTIONAL
  178. ];
  179. // Optional. Input only. Volume gain (in dB) of the normal native volume
  180. // supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
  181. // set to a value of 0.0 (dB), will play at normal native signal amplitude. A
  182. // value of -6.0 (dB) will play at approximately half the amplitude of the
  183. // normal native signal amplitude. A value of +6.0 (dB) will play at
  184. // approximately twice the amplitude of the normal native signal amplitude.
  185. // Strongly recommend not to exceed +10 (dB) as there's usually no effective
  186. // increase in loudness for any value greater than that.
  187. double volume_gain_db = 4 [
  188. (google.api.field_behavior) = INPUT_ONLY,
  189. (google.api.field_behavior) = OPTIONAL
  190. ];
  191. // Optional. The synthesis sample rate (in hertz) for this audio. When this is
  192. // specified in SynthesizeSpeechRequest, if this is different from the voice's
  193. // natural sample rate, then the synthesizer will honor this request by
  194. // converting to the desired sample rate (which might result in worse audio
  195. // quality), unless the specified sample rate is not supported for the
  196. // encoding chosen, in which case it will fail the request and return
  197. // [google.rpc.Code.INVALID_ARGUMENT][].
  198. int32 sample_rate_hertz = 5 [(google.api.field_behavior) = OPTIONAL];
  199. // Optional. Input only. An identifier which selects 'audio effects' profiles
  200. // that are applied on (post synthesized) text to speech. Effects are applied
  201. // on top of each other in the order they are given. See
  202. // [audio
  203. // profiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for
  204. // current supported profile ids.
  205. repeated string effects_profile_id = 6 [
  206. (google.api.field_behavior) = INPUT_ONLY,
  207. (google.api.field_behavior) = OPTIONAL
  208. ];
  209. }
  210. // The message returned to the client by the `SynthesizeSpeech` method.
  211. message SynthesizeSpeechResponse {
  212. // The audio data bytes encoded as specified in the request, including the
  213. // header for encodings that are wrapped in containers (e.g. MP3, OGG_OPUS).
  214. // For LINEAR16 audio, we include the WAV header. Note: as
  215. // with all bytes fields, protobuffers use a pure binary representation,
  216. // whereas JSON representations use base64.
  217. bytes audio_content = 1;
  218. }