cloud_tts.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. import "google/api/resource.proto";
  20. option cc_enable_arenas = true;
  21. option csharp_namespace = "Google.Cloud.TextToSpeech.V1Beta1";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/texttospeech/v1beta1;texttospeech";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "TextToSpeechProto";
  25. option java_package = "com.google.cloud.texttospeech.v1beta1";
  26. option php_namespace = "Google\\Cloud\\TextToSpeech\\V1beta1";
  27. option ruby_package = "Google::Cloud::TextToSpeech::V1beta1";
  28. option (google.api.resource_definition) = {
  29. type: "automl.googleapis.com/Model"
  30. pattern: "projects/{project}/locations/{location}/models/{model}"
  31. };
  32. // Service that implements Google Cloud Text-to-Speech API.
  33. service TextToSpeech {
  34. option (google.api.default_host) = "texttospeech.googleapis.com";
  35. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  36. // Returns a list of Voice supported for synthesis.
  37. rpc ListVoices(ListVoicesRequest) returns (ListVoicesResponse) {
  38. option (google.api.http) = {
  39. get: "/v1beta1/voices"
  40. };
  41. option (google.api.method_signature) = "language_code";
  42. }
  43. // Synthesizes speech synchronously: receive results after all text input
  44. // has been processed.
  45. rpc SynthesizeSpeech(SynthesizeSpeechRequest) returns (SynthesizeSpeechResponse) {
  46. option (google.api.http) = {
  47. post: "/v1beta1/text:synthesize"
  48. body: "*"
  49. };
  50. option (google.api.method_signature) = "input,voice,audio_config";
  51. }
  52. }
  53. // The top-level message sent by the client for the `ListVoices` method.
  54. message ListVoicesRequest {
  55. // Optional. Recommended.
  56. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
  57. // If not specified, the API will return all supported voices.
  58. // If specified, the ListVoices call will only return voices that can be used
  59. // to synthesize this language_code. For example, if you specify `"en-NZ"`,
  60. // all `"en-NZ"` voices will be returned. If you specify `"no"`, both
  61. // `"no-\*"` (Norwegian) and `"nb-\*"` (Norwegian Bokmal) voices will be
  62. // returned.
  63. string language_code = 1 [(google.api.field_behavior) = OPTIONAL];
  64. }
  65. // Gender of the voice as described in
  66. // [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
  67. enum SsmlVoiceGender {
  68. // An unspecified gender.
  69. // In VoiceSelectionParams, this means that the client doesn't care which
  70. // gender the selected voice will have. In the Voice field of
  71. // ListVoicesResponse, this may mean that the voice doesn't fit any of the
  72. // other categories in this enum, or that the gender of the voice isn't known.
  73. SSML_VOICE_GENDER_UNSPECIFIED = 0;
  74. // A male voice.
  75. MALE = 1;
  76. // A female voice.
  77. FEMALE = 2;
  78. // A gender-neutral voice. This voice is not yet supported.
  79. NEUTRAL = 3;
  80. }
  81. // Configuration to set up audio encoder. The encoding determines the output
  82. // audio format that we'd like.
  83. enum AudioEncoding {
  84. // Not specified. Will return result [google.rpc.Code.INVALID_ARGUMENT][].
  85. AUDIO_ENCODING_UNSPECIFIED = 0;
  86. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  87. // Audio content returned as LINEAR16 also contains a WAV header.
  88. LINEAR16 = 1;
  89. // MP3 audio at 32kbps.
  90. MP3 = 2;
  91. // MP3 at 64kbps.
  92. MP3_64_KBPS = 4;
  93. // Opus encoded audio wrapped in an ogg container. The result will be a
  94. // file which can be played natively on Android, and in browsers (at least
  95. // Chrome and Firefox). The quality of the encoding is considerably higher
  96. // than MP3 while using approximately the same bitrate.
  97. OGG_OPUS = 3;
  98. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  99. // Audio content returned as MULAW also contains a WAV header.
  100. MULAW = 5;
  101. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/A-law.
  102. // Audio content returned as ALAW also contains a WAV header.
  103. ALAW = 6;
  104. }
  105. // The message returned to the client by the `ListVoices` method.
  106. message ListVoicesResponse {
  107. // The list of voices.
  108. repeated Voice voices = 1;
  109. }
  110. // Description of a voice supported by the TTS service.
  111. message Voice {
  112. // The languages that this voice supports, expressed as
  113. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g.
  114. // "en-US", "es-419", "cmn-tw").
  115. repeated string language_codes = 1;
  116. // The name of this voice. Each distinct voice has a unique name.
  117. string name = 2;
  118. // The gender of this voice.
  119. SsmlVoiceGender ssml_gender = 3;
  120. // The natural sample rate (in hertz) for this voice.
  121. int32 natural_sample_rate_hertz = 4;
  122. }
  123. // The top-level message sent by the client for the `SynthesizeSpeech` method.
  124. message SynthesizeSpeechRequest {
  125. // The type of timepoint information that is returned in the response.
  126. enum TimepointType {
  127. // Not specified. No timepoint information will be returned.
  128. TIMEPOINT_TYPE_UNSPECIFIED = 0;
  129. // Timepoint information of `<mark>` tags in SSML input will be returned.
  130. SSML_MARK = 1;
  131. }
  132. // Required. The Synthesizer requires either plain text or SSML as input.
  133. SynthesisInput input = 1 [(google.api.field_behavior) = REQUIRED];
  134. // Required. The desired voice of the synthesized audio.
  135. VoiceSelectionParams voice = 2 [(google.api.field_behavior) = REQUIRED];
  136. // Required. The configuration of the synthesized audio.
  137. AudioConfig audio_config = 3 [(google.api.field_behavior) = REQUIRED];
  138. // Whether and what timepoints are returned in the response.
  139. repeated TimepointType enable_time_pointing = 4;
  140. }
  141. // Contains text input to be synthesized. Either `text` or `ssml` must be
  142. // supplied. Supplying both or neither returns
  143. // [google.rpc.Code.INVALID_ARGUMENT][]. The input size is limited to 5000
  144. // characters.
  145. message SynthesisInput {
  146. // The input source, which is either plain text or SSML.
  147. oneof input_source {
  148. // The raw text to be synthesized.
  149. string text = 1;
  150. // The SSML document to be synthesized. The SSML document must be valid
  151. // and well-formed. Otherwise the RPC will fail and return
  152. // [google.rpc.Code.INVALID_ARGUMENT][]. For more information, see
  153. // [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
  154. string ssml = 2;
  155. }
  156. }
  157. // Description of which voice to use for a synthesis request.
  158. message VoiceSelectionParams {
  159. // Required. The language (and potentially also the region) of the voice expressed as a
  160. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g.
  161. // "en-US". This should not include a script tag (e.g. use
  162. // "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred
  163. // from the input provided in the SynthesisInput. The TTS service
  164. // will use this parameter to help choose an appropriate voice. Note that
  165. // the TTS service may choose a voice with a slightly different language code
  166. // than the one selected; it may substitute a different region
  167. // (e.g. using en-US rather than en-CA if there isn't a Canadian voice
  168. // available), or even a different language, e.g. using "nb" (Norwegian
  169. // Bokmal) instead of "no" (Norwegian)".
  170. string language_code = 1 [(google.api.field_behavior) = REQUIRED];
  171. // The name of the voice. If not set, the service will choose a
  172. // voice based on the other parameters such as language_code and gender.
  173. string name = 2;
  174. // The preferred gender of the voice. If not set, the service will
  175. // choose a voice based on the other parameters such as language_code and
  176. // name. Note that this is only a preference, not requirement; if a
  177. // voice of the appropriate gender is not available, the synthesizer should
  178. // substitute a voice with a different gender rather than failing the request.
  179. SsmlVoiceGender ssml_gender = 3;
  180. // The configuration for a custom voice. If [CustomVoiceParams.model] is set,
  181. // the service will choose the custom voice matching the specified
  182. // configuration.
  183. CustomVoiceParams custom_voice = 4;
  184. }
  185. // Description of audio data to be synthesized.
  186. message AudioConfig {
  187. // Required. The format of the audio byte stream.
  188. AudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  189. // Optional. Input only. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is
  190. // the normal native speed supported by the specific voice. 2.0 is twice as
  191. // fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0
  192. // speed. Any other values < 0.25 or > 4.0 will return an error.
  193. double speaking_rate = 2 [
  194. (google.api.field_behavior) = INPUT_ONLY,
  195. (google.api.field_behavior) = OPTIONAL
  196. ];
  197. // Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means
  198. // increase 20 semitones from the original pitch. -20 means decrease 20
  199. // semitones from the original pitch.
  200. double pitch = 3 [
  201. (google.api.field_behavior) = INPUT_ONLY,
  202. (google.api.field_behavior) = OPTIONAL
  203. ];
  204. // Optional. Input only. Volume gain (in dB) of the normal native volume
  205. // supported by the specific voice, in the range [-96.0, 16.0]. If unset, or
  206. // set to a value of 0.0 (dB), will play at normal native signal amplitude. A
  207. // value of -6.0 (dB) will play at approximately half the amplitude of the
  208. // normal native signal amplitude. A value of +6.0 (dB) will play at
  209. // approximately twice the amplitude of the normal native signal amplitude.
  210. // Strongly recommend not to exceed +10 (dB) as there's usually no effective
  211. // increase in loudness for any value greater than that.
  212. double volume_gain_db = 4 [
  213. (google.api.field_behavior) = INPUT_ONLY,
  214. (google.api.field_behavior) = OPTIONAL
  215. ];
  216. // Optional. The synthesis sample rate (in hertz) for this audio. When this is
  217. // specified in SynthesizeSpeechRequest, if this is different from the voice's
  218. // natural sample rate, then the synthesizer will honor this request by
  219. // converting to the desired sample rate (which might result in worse audio
  220. // quality), unless the specified sample rate is not supported for the
  221. // encoding chosen, in which case it will fail the request and return
  222. // [google.rpc.Code.INVALID_ARGUMENT][].
  223. int32 sample_rate_hertz = 5 [(google.api.field_behavior) = OPTIONAL];
  224. // Optional. Input only. An identifier which selects 'audio effects' profiles
  225. // that are applied on (post synthesized) text to speech. Effects are applied
  226. // on top of each other in the order they are given. See
  227. // [audio
  228. // profiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for
  229. // current supported profile ids.
  230. repeated string effects_profile_id = 6 [
  231. (google.api.field_behavior) = INPUT_ONLY,
  232. (google.api.field_behavior) = OPTIONAL
  233. ];
  234. }
  235. // Description of the custom voice to be synthesized.
  236. message CustomVoiceParams {
  237. // The usage of the synthesized audio. You must report your honest and
  238. // correct usage of the service as it's regulated by contract and will cause
  239. // significant difference in billing.
  240. enum ReportedUsage {
  241. // Request with reported usage unspecified will be rejected.
  242. REPORTED_USAGE_UNSPECIFIED = 0;
  243. // For scenarios where the synthesized audio is not downloadable and can
  244. // only be used once. For example, real-time request in IVR system.
  245. REALTIME = 1;
  246. // For scenarios where the synthesized audio is downloadable and can be
  247. // reused. For example, the synthesized audio is downloaded, stored in
  248. // customer service system and played repeatedly.
  249. OFFLINE = 2;
  250. }
  251. // Required. The name of the AutoML model that synthesizes the custom voice.
  252. string model = 1 [
  253. (google.api.field_behavior) = REQUIRED,
  254. (google.api.resource_reference) = {
  255. type: "automl.googleapis.com/Model"
  256. }
  257. ];
  258. // Optional. The usage of the synthesized audio to be reported.
  259. ReportedUsage reported_usage = 3 [(google.api.field_behavior) = OPTIONAL];
  260. }
  261. // The message returned to the client by the `SynthesizeSpeech` method.
  262. message SynthesizeSpeechResponse {
  263. // The audio data bytes encoded as specified in the request, including the
  264. // header for encodings that are wrapped in containers (e.g. MP3, OGG_OPUS).
  265. // For LINEAR16 audio, we include the WAV header. Note: as
  266. // with all bytes fields, protobuffers use a pure binary representation,
  267. // whereas JSON representations use base64.
  268. bytes audio_content = 1;
  269. // A link between a position in the original request input and a corresponding
  270. // time in the output audio. It's only supported via `<mark>` of SSML input.
  271. repeated Timepoint timepoints = 2;
  272. // The audio metadata of `audio_content`.
  273. AudioConfig audio_config = 4;
  274. }
  275. // This contains a mapping between a certain point in the input text and a
  276. // corresponding time in the output audio.
  277. message Timepoint {
  278. // Timepoint name as received from the client within `<mark>` tag.
  279. string mark_name = 4;
  280. // Time offset in seconds from the start of the synthesized audio.
  281. double time_seconds = 3;
  282. }