audio_config.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. // Copyright 2022 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.dialogflow.cx.v3;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/protobuf/duration.proto";
  19. option cc_enable_arenas = true;
  20. option csharp_namespace = "Google.Cloud.Dialogflow.Cx.V3";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3;cx";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AudioConfigProto";
  24. option java_package = "com.google.cloud.dialogflow.cx.v3";
  25. option objc_class_prefix = "DF";
  26. option ruby_package = "Google::Cloud::Dialogflow::CX::V3";
  27. option (google.api.resource_definition) = {
  28. type: "automl.googleapis.com/Model"
  29. pattern: "projects/{project}/locations/{location}/models/{model}"
  30. };
  31. // Audio encoding of the audio content sent in the conversational query request.
  32. // Refer to the
  33. // [Cloud Speech API
  34. // documentation](https://cloud.google.com/speech-to-text/docs/basics) for more
  35. // details.
  36. enum AudioEncoding {
  37. // Not specified.
  38. AUDIO_ENCODING_UNSPECIFIED = 0;
  39. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  40. AUDIO_ENCODING_LINEAR_16 = 1;
  41. // [`FLAC`](https://xiph.org/flac/documentation.html) (Free Lossless Audio
  42. // Codec) is the recommended encoding because it is lossless (therefore
  43. // recognition is not compromised) and requires only about half the
  44. // bandwidth of `LINEAR16`. `FLAC` stream encoding supports 16-bit and
  45. // 24-bit samples, however, not all fields in `STREAMINFO` are supported.
  46. AUDIO_ENCODING_FLAC = 2;
  47. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  48. AUDIO_ENCODING_MULAW = 3;
  49. // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000.
  50. AUDIO_ENCODING_AMR = 4;
  51. // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000.
  52. AUDIO_ENCODING_AMR_WB = 5;
  53. // Opus encoded audio frames in Ogg container
  54. // ([OggOpus](https://wiki.xiph.org/OggOpus)).
  55. // `sample_rate_hertz` must be 16000.
  56. AUDIO_ENCODING_OGG_OPUS = 6;
  57. // Although the use of lossy encodings is not recommended, if a very low
  58. // bitrate encoding is required, `OGG_OPUS` is highly preferred over
  59. // Speex encoding. The [Speex](https://speex.org/) encoding supported by
  60. // Dialogflow API has a header byte in each block, as in MIME type
  61. // `audio/x-speex-with-header-byte`.
  62. // It is a variant of the RTP Speex encoding defined in
  63. // [RFC 5574](https://tools.ietf.org/html/rfc5574).
  64. // The stream is a sequence of blocks, one block per RTP packet. Each block
  65. // starts with a byte containing the length of the block, in bytes, followed
  66. // by one or more frames of Speex data, padded to an integral number of
  67. // bytes (octets) as specified in RFC 5574. In other words, each RTP header
  68. // is replaced with a single byte containing the block length. Only Speex
  69. // wideband is supported. `sample_rate_hertz` must be 16000.
  70. AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE = 7;
  71. }
  72. // Variant of the specified [Speech model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] to use.
  73. //
  74. // See the [Cloud Speech
  75. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  76. // for which models have different variants. For example, the "phone_call" model
  77. // has both a standard and an enhanced variant. When you use an enhanced model,
  78. // you will generally receive higher quality results than for a standard model.
  79. enum SpeechModelVariant {
  80. // No model variant specified. In this case Dialogflow defaults to
  81. // USE_BEST_AVAILABLE.
  82. SPEECH_MODEL_VARIANT_UNSPECIFIED = 0;
  83. // Use the best available variant of the [Speech
  84. // model][InputAudioConfig.model] that the caller is eligible for.
  85. //
  86. // Please see the [Dialogflow
  87. // docs](https://cloud.google.com/dialogflow/docs/data-logging) for
  88. // how to make your project eligible for enhanced models.
  89. USE_BEST_AVAILABLE = 1;
  90. // Use standard model variant even if an enhanced model is available. See the
  91. // [Cloud Speech
  92. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  93. // for details about enhanced models.
  94. USE_STANDARD = 2;
  95. // Use an enhanced model variant:
  96. //
  97. // * If an enhanced variant does not exist for the given
  98. // [model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] and request language, Dialogflow falls
  99. // back to the standard variant.
  100. //
  101. // The [Cloud Speech
  102. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  103. // describes which models have enhanced variants.
  104. //
  105. // * If the API caller isn't eligible for enhanced models, Dialogflow returns
  106. // an error. Please see the [Dialogflow
  107. // docs](https://cloud.google.com/dialogflow/docs/data-logging)
  108. // for how to make your project eligible.
  109. USE_ENHANCED = 3;
  110. }
  111. // Information for a word recognized by the speech recognizer.
  112. message SpeechWordInfo {
  113. // The word this info is for.
  114. string word = 3;
  115. // Time offset relative to the beginning of the audio that corresponds to the
  116. // start of the spoken word. This is an experimental feature and the accuracy
  117. // of the time offset can vary.
  118. google.protobuf.Duration start_offset = 1;
  119. // Time offset relative to the beginning of the audio that corresponds to the
  120. // end of the spoken word. This is an experimental feature and the accuracy of
  121. // the time offset can vary.
  122. google.protobuf.Duration end_offset = 2;
  123. // The Speech confidence between 0.0 and 1.0 for this word. A higher number
  124. // indicates an estimated greater likelihood that the recognized word is
  125. // correct. The default of 0.0 is a sentinel value indicating that confidence
  126. // was not set.
  127. //
  128. // This field is not guaranteed to be fully stable over time for the same
  129. // audio input. Users should also not rely on it to always be provided.
  130. float confidence = 4;
  131. }
  132. // Instructs the speech recognizer on how to process the audio content.
  133. message InputAudioConfig {
  134. // Required. Audio encoding of the audio content to process.
  135. AudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  136. // Sample rate (in Hertz) of the audio content sent in the query.
  137. // Refer to
  138. // [Cloud Speech API
  139. // documentation](https://cloud.google.com/speech-to-text/docs/basics) for
  140. // more details.
  141. int32 sample_rate_hertz = 2;
  142. // Optional. If `true`, Dialogflow returns [SpeechWordInfo][google.cloud.dialogflow.cx.v3.SpeechWordInfo] in
  143. // [StreamingRecognitionResult][google.cloud.dialogflow.cx.v3.StreamingRecognitionResult] with information about the recognized speech
  144. // words, e.g. start and end time offsets. If false or unspecified, Speech
  145. // doesn't return any word-level information.
  146. bool enable_word_info = 13;
  147. // Optional. A list of strings containing words and phrases that the speech
  148. // recognizer should recognize with higher likelihood.
  149. //
  150. // See [the Cloud Speech
  151. // documentation](https://cloud.google.com/speech-to-text/docs/basics#phrase-hints)
  152. // for more details.
  153. repeated string phrase_hints = 4;
  154. // Optional. Which Speech model to select for the given request. Select the
  155. // model best suited to your domain to get best results. If a model is not
  156. // explicitly specified, then we auto-select a model based on the parameters
  157. // in the InputAudioConfig.
  158. // If enhanced speech model is enabled for the agent and an enhanced
  159. // version of the specified model for the language does not exist, then the
  160. // speech is recognized using the standard version of the specified model.
  161. // Refer to
  162. // [Cloud Speech API
  163. // documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model)
  164. // for more details.
  165. string model = 7;
  166. // Optional. Which variant of the [Speech model][google.cloud.dialogflow.cx.v3.InputAudioConfig.model] to use.
  167. SpeechModelVariant model_variant = 10;
  168. // Optional. If `false` (default), recognition does not cease until the
  169. // client closes the stream.
  170. // If `true`, the recognizer will detect a single spoken utterance in input
  171. // audio. Recognition ceases when it detects the audio's voice has
  172. // stopped or paused. In this case, once a detected intent is received, the
  173. // client should close the stream and start a new request with a new stream as
  174. // needed.
  175. // Note: This setting is relevant only for streaming methods.
  176. bool single_utterance = 8;
  177. }
  178. // Gender of the voice as described in
  179. // [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
  180. enum SsmlVoiceGender {
  181. // An unspecified gender, which means that the client doesn't care which
  182. // gender the selected voice will have.
  183. SSML_VOICE_GENDER_UNSPECIFIED = 0;
  184. // A male voice.
  185. SSML_VOICE_GENDER_MALE = 1;
  186. // A female voice.
  187. SSML_VOICE_GENDER_FEMALE = 2;
  188. // A gender-neutral voice.
  189. SSML_VOICE_GENDER_NEUTRAL = 3;
  190. }
  191. // Description of which voice to use for speech synthesis.
  192. message VoiceSelectionParams {
  193. // Optional. The name of the voice. If not set, the service will choose a
  194. // voice based on the other parameters such as language_code and
  195. // [ssml_gender][google.cloud.dialogflow.cx.v3.VoiceSelectionParams.ssml_gender].
  196. //
  197. // For the list of available voices, please refer to [Supported voices and
  198. // languages](https://cloud.google.com/text-to-speech/docs/voices).
  199. string name = 1;
  200. // Optional. The preferred gender of the voice. If not set, the service will
  201. // choose a voice based on the other parameters such as language_code and
  202. // [name][google.cloud.dialogflow.cx.v3.VoiceSelectionParams.name]. Note that this is only a preference, not requirement. If a
  203. // voice of the appropriate gender is not available, the synthesizer
  204. // substitutes a voice with a different gender rather than failing the
  205. // request.
  206. SsmlVoiceGender ssml_gender = 2;
  207. }
  208. // Configuration of how speech should be synthesized.
  209. message SynthesizeSpeechConfig {
  210. // Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal
  211. // native speed supported by the specific voice. 2.0 is twice as fast, and
  212. // 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any
  213. // other values < 0.25 or > 4.0 will return an error.
  214. double speaking_rate = 1;
  215. // Optional. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20
  216. // semitones from the original pitch. -20 means decrease 20 semitones from the
  217. // original pitch.
  218. double pitch = 2;
  219. // Optional. Volume gain (in dB) of the normal native volume supported by the
  220. // specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of
  221. // 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB)
  222. // will play at approximately half the amplitude of the normal native signal
  223. // amplitude. A value of +6.0 (dB) will play at approximately twice the
  224. // amplitude of the normal native signal amplitude. We strongly recommend not
  225. // to exceed +10 (dB) as there's usually no effective increase in loudness for
  226. // any value greater than that.
  227. double volume_gain_db = 3;
  228. // Optional. An identifier which selects 'audio effects' profiles that are
  229. // applied on (post synthesized) text to speech. Effects are applied on top of
  230. // each other in the order they are given.
  231. repeated string effects_profile_id = 5;
  232. // Optional. The desired voice of the synthesized audio.
  233. VoiceSelectionParams voice = 4;
  234. }
  235. // Audio encoding of the output audio format in Text-To-Speech.
  236. enum OutputAudioEncoding {
  237. // Not specified.
  238. OUTPUT_AUDIO_ENCODING_UNSPECIFIED = 0;
  239. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  240. // Audio content returned as LINEAR16 also contains a WAV header.
  241. OUTPUT_AUDIO_ENCODING_LINEAR_16 = 1;
  242. // MP3 audio at 32kbps.
  243. OUTPUT_AUDIO_ENCODING_MP3 = 2;
  244. // MP3 audio at 64kbps.
  245. OUTPUT_AUDIO_ENCODING_MP3_64_KBPS = 4;
  246. // Opus encoded audio wrapped in an ogg container. The result will be a
  247. // file which can be played natively on Android, and in browsers (at least
  248. // Chrome and Firefox). The quality of the encoding is considerably higher
  249. // than MP3 while using approximately the same bitrate.
  250. OUTPUT_AUDIO_ENCODING_OGG_OPUS = 3;
  251. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  252. OUTPUT_AUDIO_ENCODING_MULAW = 5;
  253. }
  254. // Instructs the speech synthesizer how to generate the output audio content.
  255. message OutputAudioConfig {
  256. // Required. Audio encoding of the synthesized audio content.
  257. OutputAudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  258. // Optional. The synthesis sample rate (in hertz) for this audio. If not
  259. // provided, then the synthesizer will use the default sample rate based on
  260. // the audio encoding. If this is different from the voice's natural sample
  261. // rate, then the synthesizer will honor this request by converting to the
  262. // desired sample rate (which might result in worse audio quality).
  263. int32 sample_rate_hertz = 2;
  264. // Optional. Configuration of how speech should be synthesized.
  265. SynthesizeSpeechConfig synthesize_speech_config = 3;
  266. }