audio_config.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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.v3;
  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.V3";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3;cx";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "AudioConfigProto";
  25. option java_package = "com.google.cloud.dialogflow.cx.v3";
  26. option objc_class_prefix = "DF";
  27. // Information for a word recognized by the speech recognizer.
  28. message SpeechWordInfo {
  29. // The word this info is for.
  30. string word = 3;
  31. // Time offset relative to the beginning of the audio that corresponds to the
  32. // start of the spoken word. This is an experimental feature and the accuracy
  33. // of the time offset can vary.
  34. google.protobuf.Duration start_offset = 1;
  35. // Time offset relative to the beginning of the audio that corresponds to the
  36. // end of the spoken word. This is an experimental feature and the accuracy of
  37. // the time offset can vary.
  38. google.protobuf.Duration end_offset = 2;
  39. // The Speech confidence between 0.0 and 1.0 for this word. A higher number
  40. // indicates an estimated greater likelihood that the recognized word is
  41. // correct. The default of 0.0 is a sentinel value indicating that confidence
  42. // was not set.
  43. //
  44. // This field is not guaranteed to be fully stable over time for the same
  45. // audio input. Users should also not rely on it to always be provided.
  46. float confidence = 4;
  47. }
  48. // Audio encoding of the audio content sent in the conversational query request.
  49. // Refer to the
  50. // [Cloud Speech API
  51. // documentation](https://cloud.google.com/speech-to-text/docs/basics) for more
  52. // details.
  53. enum AudioEncoding {
  54. // Not specified.
  55. AUDIO_ENCODING_UNSPECIFIED = 0;
  56. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  57. AUDIO_ENCODING_LINEAR_16 = 1;
  58. // [`FLAC`](https://xiph.org/flac/documentation.html) (Free Lossless Audio
  59. // Codec) is the recommended encoding because it is lossless (therefore
  60. // recognition is not compromised) and requires only about half the
  61. // bandwidth of `LINEAR16`. `FLAC` stream encoding supports 16-bit and
  62. // 24-bit samples, however, not all fields in `STREAMINFO` are supported.
  63. AUDIO_ENCODING_FLAC = 2;
  64. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  65. AUDIO_ENCODING_MULAW = 3;
  66. // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000.
  67. AUDIO_ENCODING_AMR = 4;
  68. // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000.
  69. AUDIO_ENCODING_AMR_WB = 5;
  70. // Opus encoded audio frames in Ogg container
  71. // ([OggOpus](https://wiki.xiph.org/OggOpus)).
  72. // `sample_rate_hertz` must be 16000.
  73. AUDIO_ENCODING_OGG_OPUS = 6;
  74. // Although the use of lossy encodings is not recommended, if a very low
  75. // bitrate encoding is required, `OGG_OPUS` is highly preferred over
  76. // Speex encoding. The [Speex](https://speex.org/) encoding supported by
  77. // Dialogflow API has a header byte in each block, as in MIME type
  78. // `audio/x-speex-with-header-byte`.
  79. // It is a variant of the RTP Speex encoding defined in
  80. // [RFC 5574](https://tools.ietf.org/html/rfc5574).
  81. // The stream is a sequence of blocks, one block per RTP packet. Each block
  82. // starts with a byte containing the length of the block, in bytes, followed
  83. // by one or more frames of Speex data, padded to an integral number of
  84. // bytes (octets) as specified in RFC 5574. In other words, each RTP header
  85. // is replaced with a single byte containing the block length. Only Speex
  86. // wideband is supported. `sample_rate_hertz` must be 16000.
  87. AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE = 7;
  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.v3.SpeechWordInfo] in
  100. // [StreamingRecognitionResult][google.cloud.dialogflow.cx.v3.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.v3.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.v3.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.v3.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.v3.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.v3.VoiceSelectionParams.name]. Note that this is only a preference, not requirement. If a
  186. // voice of the appropriate gender is not available, the synthesizer
  187. // substitutes a voice with a different gender rather than failing the
  188. // request.
  189. SsmlVoiceGender ssml_gender = 2;
  190. }
  191. // Configuration of how speech should be synthesized.
  192. message SynthesizeSpeechConfig {
  193. // Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal
  194. // native speed supported by the specific voice. 2.0 is twice as fast, and
  195. // 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any
  196. // other values < 0.25 or > 4.0 will return an error.
  197. double speaking_rate = 1;
  198. // Optional. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20
  199. // semitones from the original pitch. -20 means decrease 20 semitones from the
  200. // original pitch.
  201. double pitch = 2;
  202. // Optional. Volume gain (in dB) of the normal native volume supported by the
  203. // specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of
  204. // 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB)
  205. // will play at approximately half the amplitude of the normal native signal
  206. // amplitude. A value of +6.0 (dB) will play at approximately twice the
  207. // amplitude of the normal native signal amplitude. We strongly recommend not
  208. // to exceed +10 (dB) as there's usually no effective increase in loudness for
  209. // any value greater than that.
  210. double volume_gain_db = 3;
  211. // Optional. An identifier which selects 'audio effects' profiles that are
  212. // applied on (post synthesized) text to speech. Effects are applied on top of
  213. // each other in the order they are given.
  214. repeated string effects_profile_id = 5;
  215. // Optional. The desired voice of the synthesized audio.
  216. VoiceSelectionParams voice = 4;
  217. }
  218. // Instructs the speech synthesizer how to generate the output audio content.
  219. message OutputAudioConfig {
  220. // Required. Audio encoding of the synthesized audio content.
  221. OutputAudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  222. // Optional. The synthesis sample rate (in hertz) for this audio. If not
  223. // provided, then the synthesizer will use the default sample rate based on
  224. // the audio encoding. If this is different from the voice's natural sample
  225. // rate, then the synthesizer will honor this request by converting to the
  226. // desired sample rate (which might result in worse audio quality).
  227. int32 sample_rate_hertz = 2;
  228. // Optional. Configuration of how speech should be synthesized.
  229. SynthesizeSpeechConfig synthesize_speech_config = 3;
  230. }
  231. // Gender of the voice as described in
  232. // [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
  233. enum SsmlVoiceGender {
  234. // An unspecified gender, which means that the client doesn't care which
  235. // gender the selected voice will have.
  236. SSML_VOICE_GENDER_UNSPECIFIED = 0;
  237. // A male voice.
  238. SSML_VOICE_GENDER_MALE = 1;
  239. // A female voice.
  240. SSML_VOICE_GENDER_FEMALE = 2;
  241. // A gender-neutral voice.
  242. SSML_VOICE_GENDER_NEUTRAL = 3;
  243. }
  244. // Audio encoding of the output audio format in Text-To-Speech.
  245. enum OutputAudioEncoding {
  246. // Not specified.
  247. OUTPUT_AUDIO_ENCODING_UNSPECIFIED = 0;
  248. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  249. // Audio content returned as LINEAR16 also contains a WAV header.
  250. OUTPUT_AUDIO_ENCODING_LINEAR_16 = 1;
  251. // MP3 audio at 32kbps.
  252. OUTPUT_AUDIO_ENCODING_MP3 = 2;
  253. // MP3 audio at 64kbps.
  254. OUTPUT_AUDIO_ENCODING_MP3_64_KBPS = 4;
  255. // Opus encoded audio wrapped in an ogg container. The result will be a
  256. // file which can be played natively on Android, and in browsers (at least
  257. // Chrome and Firefox). The quality of the encoding is considerably higher
  258. // than MP3 while using approximately the same bitrate.
  259. OUTPUT_AUDIO_ENCODING_OGG_OPUS = 3;
  260. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  261. OUTPUT_AUDIO_ENCODING_MULAW = 5;
  262. }