audio_config.proto 13 KB

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