cloud_tts.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.cloud.texttospeech.v1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. option cc_enable_arenas = true;
  20. option csharp_namespace = "Google.Cloud.TextToSpeech.V1Beta1";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/texttospeech/v1beta1;texttospeech";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "TextToSpeechProto";
  24. option java_package = "com.google.cloud.texttospeech.v1beta1";
  25. option php_namespace = "Google\\Cloud\\TextToSpeech\\V1beta1";
  26. option ruby_package = "Google::Cloud::TextToSpeech::V1beta1";
  27. // Service that implements Google Cloud Text-to-Speech API.
  28. service TextToSpeech {
  29. option (google.api.default_host) = "texttospeech.googleapis.com";
  30. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  31. // Returns a list of Voice supported for synthesis.
  32. rpc ListVoices(ListVoicesRequest) returns (ListVoicesResponse) {
  33. option (google.api.http) = {
  34. get: "/v1beta1/voices"
  35. };
  36. option (google.api.method_signature) = "language_code";
  37. }
  38. // Synthesizes speech synchronously: receive results after all text input
  39. // has been processed.
  40. rpc SynthesizeSpeech(SynthesizeSpeechRequest) returns (SynthesizeSpeechResponse) {
  41. option (google.api.http) = {
  42. post: "/v1beta1/text:synthesize"
  43. body: "*"
  44. };
  45. option (google.api.method_signature) = "input,voice,audio_config";
  46. }
  47. }
  48. // The top-level message sent by the client for the `ListVoices` method.
  49. message ListVoicesRequest {
  50. // Optional. Recommended.
  51. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
  52. // If not specified, the API will return all supported voices.
  53. // If specified, the ListVoices call will only return voices that can be used
  54. // to synthesize this language_code. E.g. when specifying "en-NZ", you will
  55. // get supported "en-NZ" 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-hk" 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. This voice is not yet supported.
  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. // MP3 at 64kbps.
  88. MP3_64_KBPS = 4;
  89. // Opus encoded audio wrapped in an ogg container. The result will be a
  90. // file which can be played natively on Android, and in browsers (at least
  91. // Chrome and Firefox). The quality of the encoding is considerably higher
  92. // than MP3 while using approximately the same bitrate.
  93. OGG_OPUS = 3;
  94. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  95. // Audio content returned as MULAW also contains a WAV header.
  96. MULAW = 5;
  97. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/A-law.
  98. // Audio content returned as ALAW also contains a WAV header.
  99. ALAW = 6;
  100. }
  101. // The message returned to the client by the `ListVoices` method.
  102. message ListVoicesResponse {
  103. // The list of voices.
  104. repeated Voice voices = 1;
  105. }
  106. // Description of a voice supported by the TTS service.
  107. message Voice {
  108. // The languages that this voice supports, expressed as
  109. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g.
  110. // "en-US", "es-419", "cmn-tw").
  111. repeated string language_codes = 1;
  112. // The name of this voice. Each distinct voice has a unique name.
  113. string name = 2;
  114. // The gender of this voice.
  115. SsmlVoiceGender ssml_gender = 3;
  116. // The natural sample rate (in hertz) for this voice.
  117. int32 natural_sample_rate_hertz = 4;
  118. }
  119. // The top-level message sent by the client for the `SynthesizeSpeech` method.
  120. message SynthesizeSpeechRequest {
  121. // The type of timepoint information that is returned in the response.
  122. enum TimepointType {
  123. // Not specified. No timepoint information will be returned.
  124. TIMEPOINT_TYPE_UNSPECIFIED = 0;
  125. // Timepoint information of `<mark>` tags in SSML input will be returned.
  126. SSML_MARK = 1;
  127. }
  128. // Required. The Synthesizer requires either plain text or SSML as input.
  129. SynthesisInput input = 1 [(google.api.field_behavior) = REQUIRED];
  130. // Required. The desired voice of the synthesized audio.
  131. VoiceSelectionParams voice = 2 [(google.api.field_behavior) = REQUIRED];
  132. // Required. The configuration of the synthesized audio.
  133. AudioConfig audio_config = 3 [(google.api.field_behavior) = REQUIRED];
  134. // Whether and what timepoints are returned in the response.
  135. repeated TimepointType enable_time_pointing = 4;
  136. }
  137. // Contains text input to be synthesized. Either `text` or `ssml` must be
  138. // supplied. Supplying both or neither returns
  139. // [google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to 5000
  140. // characters.
  141. message SynthesisInput {
  142. // The input source, which is either plain text or SSML.
  143. oneof input_source {
  144. // The raw text to be synthesized.
  145. string text = 1;
  146. // The SSML document to be synthesized. The SSML document must be valid
  147. // and well-formed. Otherwise the RPC will fail and return
  148. // [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
  149. // [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
  150. string ssml = 2;
  151. }
  152. }
  153. // Description of which voice to use for a synthesis request.
  154. message VoiceSelectionParams {
  155. // Required. The language (and potentially also the region) of the voice expressed as a
  156. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g.
  157. // "en-US". This should not include a script tag (e.g. use
  158. // "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
  159. // from the input provided in the SynthesisInput. The TTS service
  160. // will use this parameter to help choose an appropriate voice. Note that
  161. // the TTS service may choose a voice with a slightly different language code
  162. // than the one selected; it may substitute a different region
  163. // (e.g. using en-US rather than en-CA if there isn't a Canadian voice
  164. // available), or even a different language, e.g. using "nb" (Norwegian
  165. // Bokmal) instead of "no" (Norwegian)".
  166. string language_code = 1 [(google.api.field_behavior) = REQUIRED];
  167. // The name of the voice. If not set, the service will choose a
  168. // voice based on the other parameters such as language_code and gender.
  169. string name = 2;
  170. // The preferred gender of the voice. If not set, the service will
  171. // choose a voice based on the other parameters such as language_code and
  172. // name. Note that this is only a preference, not requirement; if a
  173. // voice of the appropriate gender is not available, the synthesizer should
  174. // substitute a voice with a different gender rather than failing the request.
  175. SsmlVoiceGender ssml_gender = 3;
  176. }
  177. // Description of audio data to be synthesized.
  178. message AudioConfig {
  179. // Required. The format of the audio byte stream.
  180. AudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  181. // Optional. Input only. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is
  182. // the normal native speed supported by the specific voice. 2.0 is twice as
  183. // fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0
  184. // speed. Any other values < 0.25 or > 4.0 will return an error.
  185. double speaking_rate = 2 [
  186. (google.api.field_behavior) = INPUT_ONLY,
  187. (google.api.field_behavior) = OPTIONAL
  188. ];
  189. // Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
  190. // increase 20 semitones from the original pitch. -20 means decrease 20
  191. // semitones from the original pitch.
  192. double pitch = 3 [
  193. (google.api.field_behavior) = INPUT_ONLY,
  194. (google.api.field_behavior) = OPTIONAL
  195. ];
  196. // Optional. Input only. Volume gain (in dB) of the normal native volume
  197. // supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
  198. // set to a value of 0.0 (dB), will play at normal native signal amplitude. A
  199. // value of -6.0 (dB) will play at approximately half the amplitude of the
  200. // normal native signal amplitude. A value of +6.0 (dB) will play at
  201. // approximately twice the amplitude of the normal native signal amplitude.
  202. // Strongly recommend not to exceed +10 (dB) as there's usually no effective
  203. // increase in loudness for any value greater than that.
  204. double volume_gain_db = 4 [
  205. (google.api.field_behavior) = INPUT_ONLY,
  206. (google.api.field_behavior) = OPTIONAL
  207. ];
  208. // Optional. The synthesis sample rate (in hertz) for this audio. When this is
  209. // specified in SynthesizeSpeechRequest, if this is different from the voice's
  210. // natural sample rate, then the synthesizer will honor this request by
  211. // converting to the desired sample rate (which might result in worse audio
  212. // quality), unless the specified sample rate is not supported for the
  213. // encoding chosen, in which case it will fail the request and return
  214. // [google.rpc.Code.INVALID_ARGUMENT][].
  215. int32 sample_rate_hertz = 5 [(google.api.field_behavior) = OPTIONAL];
  216. // Optional. Input only. An identifier which selects 'audio effects' profiles
  217. // that are applied on (post synthesized) text to speech. Effects are applied
  218. // on top of each other in the order they are given. See
  219. // [audio
  220. // profiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for
  221. // current supported profile ids.
  222. repeated string effects_profile_id = 6 [
  223. (google.api.field_behavior) = INPUT_ONLY,
  224. (google.api.field_behavior) = OPTIONAL
  225. ];
  226. }
  227. // The message returned to the client by the `SynthesizeSpeech` method.
  228. message SynthesizeSpeechResponse {
  229. // The audio data bytes encoded as specified in the request, including the
  230. // header for encodings that are wrapped in containers (e.g. MP3, OGG_OPUS).
  231. // For LINEAR16 audio, we include the WAV header. Note: as
  232. // with all bytes fields, protobuffers use a pure binary representation,
  233. // whereas JSON representations use base64.
  234. bytes audio_content = 1;
  235. // A link between a position in the original request input and a corresponding
  236. // time in the output audio. It's only supported via `<mark>` of SSML input.
  237. repeated Timepoint timepoints = 2;
  238. // The audio metadata of `audio_content`.
  239. AudioConfig audio_config = 4;
  240. }
  241. // This contains a mapping between a certain point in the input text and a
  242. // corresponding time in the output audio.
  243. message Timepoint {
  244. // Timepoint name as received from the client within `<mark>` tag.
  245. string mark_name = 4;
  246. // Time offset in seconds from the start of the synthesized audio.
  247. double time_seconds = 3;
  248. }