audio_config.proto 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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.v2;
  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.V2";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2;dialogflow";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AudioConfigProto";
  24. option java_package = "com.google.cloud.dialogflow.v2";
  25. option objc_class_prefix = "DF";
  26. option (google.api.resource_definition) = {
  27. type: "automl.googleapis.com/Model"
  28. pattern: "projects/{project}/locations/{location}/models/{model}"
  29. };
  30. option (google.api.resource_definition) = {
  31. type: "speech.googleapis.com/PhraseSet"
  32. pattern: "projects/{project}/locations/{location}/phraseSets/{phrase_set}"
  33. };
  34. // Audio encoding of the audio content sent in the conversational query request.
  35. // Refer to the
  36. // [Cloud Speech API
  37. // documentation](https://cloud.google.com/speech-to-text/docs/basics) for more
  38. // details.
  39. enum AudioEncoding {
  40. // Not specified.
  41. AUDIO_ENCODING_UNSPECIFIED = 0;
  42. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  43. AUDIO_ENCODING_LINEAR_16 = 1;
  44. // [`FLAC`](https://xiph.org/flac/documentation.html) (Free Lossless Audio
  45. // Codec) is the recommended encoding because it is lossless (therefore
  46. // recognition is not compromised) and requires only about half the
  47. // bandwidth of `LINEAR16`. `FLAC` stream encoding supports 16-bit and
  48. // 24-bit samples, however, not all fields in `STREAMINFO` are supported.
  49. AUDIO_ENCODING_FLAC = 2;
  50. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  51. AUDIO_ENCODING_MULAW = 3;
  52. // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000.
  53. AUDIO_ENCODING_AMR = 4;
  54. // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000.
  55. AUDIO_ENCODING_AMR_WB = 5;
  56. // Opus encoded audio frames in Ogg container
  57. // ([OggOpus](https://wiki.xiph.org/OggOpus)).
  58. // `sample_rate_hertz` must be 16000.
  59. AUDIO_ENCODING_OGG_OPUS = 6;
  60. // Although the use of lossy encodings is not recommended, if a very low
  61. // bitrate encoding is required, `OGG_OPUS` is highly preferred over
  62. // Speex encoding. The [Speex](https://speex.org/) encoding supported by
  63. // Dialogflow API has a header byte in each block, as in MIME type
  64. // `audio/x-speex-with-header-byte`.
  65. // It is a variant of the RTP Speex encoding defined in
  66. // [RFC 5574](https://tools.ietf.org/html/rfc5574).
  67. // The stream is a sequence of blocks, one block per RTP packet. Each block
  68. // starts with a byte containing the length of the block, in bytes, followed
  69. // by one or more frames of Speex data, padded to an integral number of
  70. // bytes (octets) as specified in RFC 5574. In other words, each RTP header
  71. // is replaced with a single byte containing the block length. Only Speex
  72. // wideband is supported. `sample_rate_hertz` must be 16000.
  73. AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE = 7;
  74. }
  75. // Hints for the speech recognizer to help with recognition in a specific
  76. // conversation state.
  77. message SpeechContext {
  78. // Optional. A list of strings containing words and phrases that the speech
  79. // recognizer should recognize with higher likelihood.
  80. //
  81. // This list can be used to:
  82. //
  83. // * improve accuracy for words and phrases you expect the user to say,
  84. // e.g. typical commands for your Dialogflow agent
  85. // * add additional words to the speech recognizer vocabulary
  86. // * ...
  87. //
  88. // See the [Cloud Speech
  89. // documentation](https://cloud.google.com/speech-to-text/quotas) for usage
  90. // limits.
  91. repeated string phrases = 1;
  92. // Optional. Boost for this context compared to other contexts:
  93. //
  94. // * If the boost is positive, Dialogflow will increase the probability that
  95. // the phrases in this context are recognized over similar sounding phrases.
  96. // * If the boost is unspecified or non-positive, Dialogflow will not apply
  97. // any boost.
  98. //
  99. // Dialogflow recommends that you use boosts in the range (0, 20] and that you
  100. // find a value that fits your use case with binary search.
  101. float boost = 2;
  102. }
  103. // Variant of the specified [Speech model][google.cloud.dialogflow.v2.InputAudioConfig.model] to use.
  104. //
  105. // See the [Cloud Speech
  106. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  107. // for which models have different variants. For example, the "phone_call" model
  108. // has both a standard and an enhanced variant. When you use an enhanced model,
  109. // you will generally receive higher quality results than for a standard model.
  110. enum SpeechModelVariant {
  111. // No model variant specified. In this case Dialogflow defaults to
  112. // USE_BEST_AVAILABLE.
  113. SPEECH_MODEL_VARIANT_UNSPECIFIED = 0;
  114. // Use the best available variant of the [Speech
  115. // model][InputAudioConfig.model] that the caller is eligible for.
  116. //
  117. // Please see the [Dialogflow
  118. // docs](https://cloud.google.com/dialogflow/docs/data-logging) for
  119. // how to make your project eligible for enhanced models.
  120. USE_BEST_AVAILABLE = 1;
  121. // Use standard model variant even if an enhanced model is available. See the
  122. // [Cloud Speech
  123. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  124. // for details about enhanced models.
  125. USE_STANDARD = 2;
  126. // Use an enhanced model variant:
  127. //
  128. // * If an enhanced variant does not exist for the given
  129. // [model][google.cloud.dialogflow.v2.InputAudioConfig.model] and request language, Dialogflow falls
  130. // back to the standard variant.
  131. //
  132. // The [Cloud Speech
  133. // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models)
  134. // describes which models have enhanced variants.
  135. //
  136. // * If the API caller isn't eligible for enhanced models, Dialogflow returns
  137. // an error. Please see the [Dialogflow
  138. // docs](https://cloud.google.com/dialogflow/docs/data-logging)
  139. // for how to make your project eligible.
  140. USE_ENHANCED = 3;
  141. }
  142. // Information for a word recognized by the speech recognizer.
  143. message SpeechWordInfo {
  144. // The word this info is for.
  145. string word = 3;
  146. // Time offset relative to the beginning of the audio that corresponds to the
  147. // start of the spoken word. This is an experimental feature and the accuracy
  148. // of the time offset can vary.
  149. google.protobuf.Duration start_offset = 1;
  150. // Time offset relative to the beginning of the audio that corresponds to the
  151. // end of the spoken word. This is an experimental feature and the accuracy of
  152. // the time offset can vary.
  153. google.protobuf.Duration end_offset = 2;
  154. // The Speech confidence between 0.0 and 1.0 for this word. A higher number
  155. // indicates an estimated greater likelihood that the recognized word is
  156. // correct. The default of 0.0 is a sentinel value indicating that confidence
  157. // was not set.
  158. //
  159. // This field is not guaranteed to be fully stable over time for the same
  160. // audio input. Users should also not rely on it to always be provided.
  161. float confidence = 4;
  162. }
  163. // Instructs the speech recognizer how to process the audio content.
  164. message InputAudioConfig {
  165. // Required. Audio encoding of the audio content to process.
  166. AudioEncoding audio_encoding = 1;
  167. // Required. Sample rate (in Hertz) of the audio content sent in the query.
  168. // Refer to
  169. // [Cloud Speech API
  170. // documentation](https://cloud.google.com/speech-to-text/docs/basics) for
  171. // more details.
  172. int32 sample_rate_hertz = 2;
  173. // Required. The language of the supplied audio. Dialogflow does not do
  174. // translations. See [Language
  175. // Support](https://cloud.google.com/dialogflow/docs/reference/language)
  176. // for a list of the currently supported language codes. Note that queries in
  177. // the same session do not necessarily need to specify the same language.
  178. string language_code = 3;
  179. // If `true`, Dialogflow returns [SpeechWordInfo][google.cloud.dialogflow.v2.SpeechWordInfo] in
  180. // [StreamingRecognitionResult][google.cloud.dialogflow.v2.StreamingRecognitionResult] with information about the recognized speech
  181. // words, e.g. start and end time offsets. If false or unspecified, Speech
  182. // doesn't return any word-level information.
  183. bool enable_word_info = 13;
  184. // A list of strings containing words and phrases that the speech
  185. // recognizer should recognize with higher likelihood.
  186. //
  187. // See [the Cloud Speech
  188. // documentation](https://cloud.google.com/speech-to-text/docs/basics#phrase-hints)
  189. // for more details.
  190. //
  191. // This field is deprecated. Please use [speech_contexts]() instead. If you
  192. // specify both [phrase_hints]() and [speech_contexts](), Dialogflow will
  193. // treat the [phrase_hints]() as a single additional [SpeechContext]().
  194. repeated string phrase_hints = 4 [deprecated = true];
  195. // Context information to assist speech recognition.
  196. //
  197. // See [the Cloud Speech
  198. // documentation](https://cloud.google.com/speech-to-text/docs/basics#phrase-hints)
  199. // for more details.
  200. repeated SpeechContext speech_contexts = 11;
  201. // Which Speech model to select for the given request. Select the
  202. // model best suited to your domain to get best results. If a model is not
  203. // explicitly specified, then we auto-select a model based on the parameters
  204. // in the InputAudioConfig.
  205. // If enhanced speech model is enabled for the agent and an enhanced
  206. // version of the specified model for the language does not exist, then the
  207. // speech is recognized using the standard version of the specified model.
  208. // Refer to
  209. // [Cloud Speech API
  210. // documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model)
  211. // for more details.
  212. string model = 7;
  213. // Which variant of the [Speech model][google.cloud.dialogflow.v2.InputAudioConfig.model] to use.
  214. SpeechModelVariant model_variant = 10;
  215. // If `false` (default), recognition does not cease until the
  216. // client closes the stream.
  217. // If `true`, the recognizer will detect a single spoken utterance in input
  218. // audio. Recognition ceases when it detects the audio's voice has
  219. // stopped or paused. In this case, once a detected intent is received, the
  220. // client should close the stream and start a new request with a new stream as
  221. // needed.
  222. // Note: This setting is relevant only for streaming methods.
  223. // Note: When specified, InputAudioConfig.single_utterance takes precedence
  224. // over StreamingDetectIntentRequest.single_utterance.
  225. bool single_utterance = 8;
  226. // Only used in [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent] and
  227. // [Participants.StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent].
  228. // If `false` and recognition doesn't return any result, trigger
  229. // `NO_SPEECH_RECOGNIZED` event to Dialogflow agent.
  230. bool disable_no_speech_recognized_event = 14;
  231. }
  232. // Gender of the voice as described in
  233. // [SSML voice element](https://www.w3.org/TR/speech-synthesis11/#edef_voice).
  234. enum SsmlVoiceGender {
  235. // An unspecified gender, which means that the client doesn't care which
  236. // gender the selected voice will have.
  237. SSML_VOICE_GENDER_UNSPECIFIED = 0;
  238. // A male voice.
  239. SSML_VOICE_GENDER_MALE = 1;
  240. // A female voice.
  241. SSML_VOICE_GENDER_FEMALE = 2;
  242. // A gender-neutral voice.
  243. SSML_VOICE_GENDER_NEUTRAL = 3;
  244. }
  245. // Description of which voice to use for speech synthesis.
  246. message VoiceSelectionParams {
  247. // Optional. The name of the voice. If not set, the service will choose a
  248. // voice based on the other parameters such as language_code and
  249. // [ssml_gender][google.cloud.dialogflow.v2.VoiceSelectionParams.ssml_gender].
  250. string name = 1;
  251. // Optional. The preferred gender of the voice. If not set, the service will
  252. // choose a voice based on the other parameters such as language_code and
  253. // [name][google.cloud.dialogflow.v2.VoiceSelectionParams.name]. Note that this is only a preference, not requirement. If a
  254. // voice of the appropriate gender is not available, the synthesizer should
  255. // substitute a voice with a different gender rather than failing the request.
  256. SsmlVoiceGender ssml_gender = 2;
  257. }
  258. // Configuration of how speech should be synthesized.
  259. message SynthesizeSpeechConfig {
  260. // Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal
  261. // native speed supported by the specific voice. 2.0 is twice as fast, and
  262. // 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any
  263. // other values < 0.25 or > 4.0 will return an error.
  264. double speaking_rate = 1;
  265. // Optional. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20
  266. // semitones from the original pitch. -20 means decrease 20 semitones from the
  267. // original pitch.
  268. double pitch = 2;
  269. // Optional. Volume gain (in dB) of the normal native volume supported by the
  270. // specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of
  271. // 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB)
  272. // will play at approximately half the amplitude of the normal native signal
  273. // amplitude. A value of +6.0 (dB) will play at approximately twice the
  274. // amplitude of the normal native signal amplitude. We strongly recommend not
  275. // to exceed +10 (dB) as there's usually no effective increase in loudness for
  276. // any value greater than that.
  277. double volume_gain_db = 3;
  278. // Optional. An identifier which selects 'audio effects' profiles that are
  279. // applied on (post synthesized) text to speech. Effects are applied on top of
  280. // each other in the order they are given.
  281. repeated string effects_profile_id = 5;
  282. // Optional. The desired voice of the synthesized audio.
  283. VoiceSelectionParams voice = 4;
  284. }
  285. // Audio encoding of the output audio format in Text-To-Speech.
  286. enum OutputAudioEncoding {
  287. // Not specified.
  288. OUTPUT_AUDIO_ENCODING_UNSPECIFIED = 0;
  289. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  290. // Audio content returned as LINEAR16 also contains a WAV header.
  291. OUTPUT_AUDIO_ENCODING_LINEAR_16 = 1;
  292. // MP3 audio at 32kbps.
  293. OUTPUT_AUDIO_ENCODING_MP3 = 2;
  294. // MP3 audio at 64kbps.
  295. OUTPUT_AUDIO_ENCODING_MP3_64_KBPS = 4;
  296. // Opus encoded audio wrapped in an ogg container. The result will be a
  297. // file which can be played natively on Android, and in browsers (at least
  298. // Chrome and Firefox). The quality of the encoding is considerably higher
  299. // than MP3 while using approximately the same bitrate.
  300. OUTPUT_AUDIO_ENCODING_OGG_OPUS = 3;
  301. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  302. OUTPUT_AUDIO_ENCODING_MULAW = 5;
  303. }
  304. // Instructs the speech synthesizer on how to generate the output audio content.
  305. // If this audio config is supplied in a request, it overrides all existing
  306. // text-to-speech settings applied to the agent.
  307. message OutputAudioConfig {
  308. // Required. Audio encoding of the synthesized audio content.
  309. OutputAudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED];
  310. // The synthesis sample rate (in hertz) for this audio. If not
  311. // provided, then the synthesizer will use the default sample rate based on
  312. // the audio encoding. If this is different from the voice's natural sample
  313. // rate, then the synthesizer will honor this request by converting to the
  314. // desired sample rate (which might result in worse audio quality).
  315. int32 sample_rate_hertz = 2;
  316. // Configuration of how speech should be synthesized.
  317. SynthesizeSpeechConfig synthesize_speech_config = 3;
  318. }
  319. // [DTMF](https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling)
  320. // digit in Telephony Gateway.
  321. enum TelephonyDtmf {
  322. // Not specified. This value may be used to indicate an absent digit.
  323. TELEPHONY_DTMF_UNSPECIFIED = 0;
  324. // Number: '1'.
  325. DTMF_ONE = 1;
  326. // Number: '2'.
  327. DTMF_TWO = 2;
  328. // Number: '3'.
  329. DTMF_THREE = 3;
  330. // Number: '4'.
  331. DTMF_FOUR = 4;
  332. // Number: '5'.
  333. DTMF_FIVE = 5;
  334. // Number: '6'.
  335. DTMF_SIX = 6;
  336. // Number: '7'.
  337. DTMF_SEVEN = 7;
  338. // Number: '8'.
  339. DTMF_EIGHT = 8;
  340. // Number: '9'.
  341. DTMF_NINE = 9;
  342. // Number: '0'.
  343. DTMF_ZERO = 10;
  344. // Letter: 'A'.
  345. DTMF_A = 11;
  346. // Letter: 'B'.
  347. DTMF_B = 12;
  348. // Letter: 'C'.
  349. DTMF_C = 13;
  350. // Letter: 'D'.
  351. DTMF_D = 14;
  352. // Asterisk/star: '*'.
  353. DTMF_STAR = 15;
  354. // Pound/diamond/hash/square/gate/octothorpe: '#'.
  355. DTMF_POUND = 16;
  356. }
  357. // A wrapper of repeated TelephonyDtmf digits.
  358. message TelephonyDtmfEvents {
  359. // A sequence of TelephonyDtmf digits.
  360. repeated TelephonyDtmf dtmf_events = 1;
  361. }
  362. // Configures speech transcription for [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile].
  363. message SpeechToTextConfig {
  364. // The speech model used in speech to text.
  365. // `SPEECH_MODEL_VARIANT_UNSPECIFIED`, `USE_BEST_AVAILABLE` will be treated as
  366. // `USE_ENHANCED`. It can be overridden in [AnalyzeContentRequest][google.cloud.dialogflow.v2.AnalyzeContentRequest] and
  367. // [StreamingAnalyzeContentRequest][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest] request.
  368. // If enhanced model variant is specified and an enhanced
  369. // version of the specified model for the language does not exist, then it
  370. // would emit an error.
  371. SpeechModelVariant speech_model_variant = 1;
  372. // Which Speech model to select. Select the model best suited to your domain
  373. // to get best results. If a model is not explicitly specified, then a default
  374. // model is used.
  375. // Refer to
  376. // [Cloud Speech API
  377. // documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model)
  378. // for more details.
  379. string model = 2;
  380. }