cloud_speech.proto 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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.speech.v1p1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/cloud/speech/v1p1beta1/resource.proto";
  20. import "google/longrunning/operations.proto";
  21. import "google/protobuf/duration.proto";
  22. import "google/protobuf/timestamp.proto";
  23. import "google/protobuf/wrappers.proto";
  24. import "google/rpc/status.proto";
  25. option cc_enable_arenas = true;
  26. option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "SpeechProto";
  29. option java_package = "com.google.cloud.speech.v1p1beta1";
  30. option objc_class_prefix = "GCS";
  31. // Service that implements Google Cloud Speech API.
  32. service Speech {
  33. option (google.api.default_host) = "speech.googleapis.com";
  34. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  35. // Performs synchronous speech recognition: receive results after all audio
  36. // has been sent and processed.
  37. rpc Recognize(RecognizeRequest) returns (RecognizeResponse) {
  38. option (google.api.http) = {
  39. post: "/v1p1beta1/speech:recognize"
  40. body: "*"
  41. };
  42. option (google.api.method_signature) = "config,audio";
  43. }
  44. // Performs asynchronous speech recognition: receive results via the
  45. // google.longrunning.Operations interface. Returns either an
  46. // `Operation.error` or an `Operation.response` which contains
  47. // a `LongRunningRecognizeResponse` message.
  48. // For more information on asynchronous speech recognition, see the
  49. // [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
  50. rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) {
  51. option (google.api.http) = {
  52. post: "/v1p1beta1/speech:longrunningrecognize"
  53. body: "*"
  54. };
  55. option (google.api.method_signature) = "config,audio";
  56. option (google.longrunning.operation_info) = {
  57. response_type: "LongRunningRecognizeResponse"
  58. metadata_type: "LongRunningRecognizeMetadata"
  59. };
  60. }
  61. // Performs bidirectional streaming speech recognition: receive results while
  62. // sending audio. This method is only available via the gRPC API (not REST).
  63. rpc StreamingRecognize(stream StreamingRecognizeRequest) returns (stream StreamingRecognizeResponse) {
  64. }
  65. }
  66. // The top-level message sent by the client for the `Recognize` method.
  67. message RecognizeRequest {
  68. // Required. Provides information to the recognizer that specifies how to
  69. // process the request.
  70. RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED];
  71. // Required. The audio data to be recognized.
  72. RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED];
  73. }
  74. // The top-level message sent by the client for the `LongRunningRecognize`
  75. // method.
  76. message LongRunningRecognizeRequest {
  77. // Required. Provides information to the recognizer that specifies how to
  78. // process the request.
  79. RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED];
  80. // Required. The audio data to be recognized.
  81. RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED];
  82. // Optional. Specifies an optional destination for the recognition results.
  83. TranscriptOutputConfig output_config = 4 [(google.api.field_behavior) = OPTIONAL];
  84. }
  85. // Specifies an optional destination for the recognition results.
  86. message TranscriptOutputConfig {
  87. oneof output_type {
  88. // Specifies a Cloud Storage URI for the recognition results. Must be
  89. // specified in the format: `gs://bucket_name/object_name`, and the bucket
  90. // must already exist.
  91. string gcs_uri = 1;
  92. }
  93. }
  94. // The top-level message sent by the client for the `StreamingRecognize` method.
  95. // Multiple `StreamingRecognizeRequest` messages are sent. The first message
  96. // must contain a `streaming_config` message and must not contain
  97. // `audio_content`. All subsequent messages must contain `audio_content` and
  98. // must not contain a `streaming_config` message.
  99. message StreamingRecognizeRequest {
  100. // The streaming request, which is either a streaming config or audio content.
  101. oneof streaming_request {
  102. // Provides information to the recognizer that specifies how to process the
  103. // request. The first `StreamingRecognizeRequest` message must contain a
  104. // `streaming_config` message.
  105. StreamingRecognitionConfig streaming_config = 1;
  106. // The audio data to be recognized. Sequential chunks of audio data are sent
  107. // in sequential `StreamingRecognizeRequest` messages. The first
  108. // `StreamingRecognizeRequest` message must not contain `audio_content` data
  109. // and all subsequent `StreamingRecognizeRequest` messages must contain
  110. // `audio_content` data. The audio bytes must be encoded as specified in
  111. // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a
  112. // pure binary representation (not base64). See
  113. // [content limits](https://cloud.google.com/speech-to-text/quotas#content).
  114. bytes audio_content = 2;
  115. }
  116. }
  117. // Provides information to the recognizer that specifies how to process the
  118. // request.
  119. message StreamingRecognitionConfig {
  120. // Required. Provides information to the recognizer that specifies how to
  121. // process the request.
  122. RecognitionConfig config = 1 [(google.api.field_behavior) = REQUIRED];
  123. // If `false` or omitted, the recognizer will perform continuous
  124. // recognition (continuing to wait for and process audio even if the user
  125. // pauses speaking) until the client closes the input stream (gRPC API) or
  126. // until the maximum time limit has been reached. May return multiple
  127. // `StreamingRecognitionResult`s with the `is_final` flag set to `true`.
  128. //
  129. // If `true`, the recognizer will detect a single spoken utterance. When it
  130. // detects that the user has paused or stopped speaking, it will return an
  131. // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no
  132. // more than one `StreamingRecognitionResult` with the `is_final` flag set to
  133. // `true`.
  134. //
  135. // The `single_utterance` field can only be used with specified models,
  136. // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][]
  137. // must be set to:
  138. //
  139. // * `command_and_search`
  140. // * `phone_call` AND additional field `useEnhanced`=`true`
  141. // * The `model` field is left undefined. In this case the API auto-selects
  142. // a model based on any other parameters that you set in
  143. // `RecognitionConfig`.
  144. bool single_utterance = 2;
  145. // If `true`, interim results (tentative hypotheses) may be
  146. // returned as they become available (these interim results are indicated with
  147. // the `is_final=false` flag).
  148. // If `false` or omitted, only `is_final=true` result(s) are returned.
  149. bool interim_results = 3;
  150. }
  151. // Provides information to the recognizer that specifies how to process the
  152. // request.
  153. message RecognitionConfig {
  154. // The encoding of the audio data sent in the request.
  155. //
  156. // All encodings support only 1 channel (mono) audio, unless the
  157. // `audio_channel_count` and `enable_separate_recognition_per_channel` fields
  158. // are set.
  159. //
  160. // For best results, the audio source should be captured and transmitted using
  161. // a lossless encoding (`FLAC` or `LINEAR16`). The accuracy of the speech
  162. // recognition can be reduced if lossy codecs are used to capture or transmit
  163. // audio, particularly if background noise is present. Lossy codecs include
  164. // `MULAW`, `AMR`, `AMR_WB`, `OGG_OPUS`, `SPEEX_WITH_HEADER_BYTE`, `MP3`,
  165. // and `WEBM_OPUS`.
  166. //
  167. // The `FLAC` and `WAV` audio file formats include a header that describes the
  168. // included audio content. You can request recognition for `WAV` files that
  169. // contain either `LINEAR16` or `MULAW` encoded audio.
  170. // If you send `FLAC` or `WAV` audio file format in
  171. // your request, you do not need to specify an `AudioEncoding`; the audio
  172. // encoding format is determined from the file header. If you specify
  173. // an `AudioEncoding` when you send send `FLAC` or `WAV` audio, the
  174. // encoding configuration must match the encoding described in the audio
  175. // header; otherwise the request returns an
  176. // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code.
  177. enum AudioEncoding {
  178. // Not specified.
  179. ENCODING_UNSPECIFIED = 0;
  180. // Uncompressed 16-bit signed little-endian samples (Linear PCM).
  181. LINEAR16 = 1;
  182. // `FLAC` (Free Lossless Audio
  183. // Codec) is the recommended encoding because it is
  184. // lossless--therefore recognition is not compromised--and
  185. // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream
  186. // encoding supports 16-bit and 24-bit samples, however, not all fields in
  187. // `STREAMINFO` are supported.
  188. FLAC = 2;
  189. // 8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
  190. MULAW = 3;
  191. // Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 8000.
  192. AMR = 4;
  193. // Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 16000.
  194. AMR_WB = 5;
  195. // Opus encoded audio frames in Ogg container
  196. // ([OggOpus](https://wiki.xiph.org/OggOpus)).
  197. // `sample_rate_hertz` must be one of 8000, 12000, 16000, 24000, or 48000.
  198. OGG_OPUS = 6;
  199. // Although the use of lossy encodings is not recommended, if a very low
  200. // bitrate encoding is required, `OGG_OPUS` is highly preferred over
  201. // Speex encoding. The [Speex](https://speex.org/) encoding supported by
  202. // Cloud Speech API has a header byte in each block, as in MIME type
  203. // `audio/x-speex-with-header-byte`.
  204. // It is a variant of the RTP Speex encoding defined in
  205. // [RFC 5574](https://tools.ietf.org/html/rfc5574).
  206. // The stream is a sequence of blocks, one block per RTP packet. Each block
  207. // starts with a byte containing the length of the block, in bytes, followed
  208. // by one or more frames of Speex data, padded to an integral number of
  209. // bytes (octets) as specified in RFC 5574. In other words, each RTP header
  210. // is replaced with a single byte containing the block length. Only Speex
  211. // wideband is supported. `sample_rate_hertz` must be 16000.
  212. SPEEX_WITH_HEADER_BYTE = 7;
  213. // MP3 audio. MP3 encoding is a Beta feature and only available in
  214. // v1p1beta1. Support all standard MP3 bitrates (which range from 32-320
  215. // kbps). When using this encoding, `sample_rate_hertz` has to match the
  216. // sample rate of the file being used.
  217. MP3 = 8;
  218. // Opus encoded audio frames in WebM container
  219. // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be
  220. // one of 8000, 12000, 16000, 24000, or 48000.
  221. WEBM_OPUS = 9;
  222. }
  223. // Encoding of audio data sent in all `RecognitionAudio` messages.
  224. // This field is optional for `FLAC` and `WAV` audio files and required
  225. // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding].
  226. AudioEncoding encoding = 1;
  227. // Sample rate in Hertz of the audio data sent in all
  228. // `RecognitionAudio` messages. Valid values are: 8000-48000.
  229. // 16000 is optimal. For best results, set the sampling rate of the audio
  230. // source to 16000 Hz. If that's not possible, use the native sample rate of
  231. // the audio source (instead of re-sampling).
  232. // This field is optional for FLAC and WAV audio files, but is
  233. // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1p1beta1.RecognitionConfig.AudioEncoding].
  234. int32 sample_rate_hertz = 2;
  235. // The number of channels in the input audio data.
  236. // ONLY set this for MULTI-CHANNEL recognition.
  237. // Valid values for LINEAR16 and FLAC are `1`-`8`.
  238. // Valid values for OGG_OPUS are '1'-'254'.
  239. // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`.
  240. // If `0` or omitted, defaults to one channel (mono).
  241. // Note: We only recognize the first channel by default.
  242. // To perform independent recognition on each channel set
  243. // `enable_separate_recognition_per_channel` to 'true'.
  244. int32 audio_channel_count = 7;
  245. // This needs to be set to `true` explicitly and `audio_channel_count` > 1
  246. // to get each channel recognized separately. The recognition result will
  247. // contain a `channel_tag` field to state which channel that result belongs
  248. // to. If this is not true, we will only recognize the first channel. The
  249. // request is billed cumulatively for all channels recognized:
  250. // `audio_channel_count` multiplied by the length of the audio.
  251. bool enable_separate_recognition_per_channel = 12;
  252. // Required. The language of the supplied audio as a
  253. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
  254. // Example: "en-US".
  255. // See [Language
  256. // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list
  257. // of the currently supported language codes.
  258. string language_code = 3 [(google.api.field_behavior) = REQUIRED];
  259. // A list of up to 3 additional
  260. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags,
  261. // listing possible alternative languages of the supplied audio.
  262. // See [Language
  263. // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list
  264. // of the currently supported language codes. If alternative languages are
  265. // listed, recognition result will contain recognition in the most likely
  266. // language detected including the main language_code. The recognition result
  267. // will include the language tag of the language detected in the audio. Note:
  268. // This feature is only supported for Voice Command and Voice Search use cases
  269. // and performance may vary for other use cases (e.g., phone call
  270. // transcription).
  271. repeated string alternative_language_codes = 18;
  272. // Maximum number of recognition hypotheses to be returned.
  273. // Specifically, the maximum number of `SpeechRecognitionAlternative` messages
  274. // within each `SpeechRecognitionResult`.
  275. // The server may return fewer than `max_alternatives`.
  276. // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of
  277. // one. If omitted, will return a maximum of one.
  278. int32 max_alternatives = 4;
  279. // If set to `true`, the server will attempt to filter out
  280. // profanities, replacing all but the initial character in each filtered word
  281. // with asterisks, e.g. "f***". If set to `false` or omitted, profanities
  282. // won't be filtered out.
  283. bool profanity_filter = 5;
  284. // Speech adaptation configuration improves the accuracy of speech
  285. // recognition. For more information, see the [speech
  286. // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation)
  287. // documentation.
  288. // When speech adaptation is set it supersedes the `speech_contexts` field.
  289. SpeechAdaptation adaptation = 20;
  290. // Use transcription normalization to automatically replace parts of the
  291. // transcript with phrases of your choosing. For StreamingRecognize, this
  292. // normalization only applies to stable partial transcripts (stability > 0.8)
  293. // and final transcripts.
  294. TranscriptNormalization transcript_normalization = 24;
  295. // Array of [SpeechContext][google.cloud.speech.v1p1beta1.SpeechContext].
  296. // A means to provide context to assist the speech recognition. For more
  297. // information, see
  298. // [speech
  299. // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation).
  300. repeated SpeechContext speech_contexts = 6;
  301. // If `true`, the top result includes a list of words and
  302. // the start and end time offsets (timestamps) for those words. If
  303. // `false`, no word-level time offset information is returned. The default is
  304. // `false`.
  305. bool enable_word_time_offsets = 8;
  306. // If `true`, the top result includes a list of words and the
  307. // confidence for those words. If `false`, no word-level confidence
  308. // information is returned. The default is `false`.
  309. bool enable_word_confidence = 15;
  310. // If 'true', adds punctuation to recognition result hypotheses.
  311. // This feature is only available in select languages. Setting this for
  312. // requests in other languages has no effect at all.
  313. // The default 'false' value does not add punctuation to result hypotheses.
  314. bool enable_automatic_punctuation = 11;
  315. // The spoken punctuation behavior for the call
  316. // If not set, uses default behavior based on model of choice
  317. // e.g. command_and_search will enable spoken punctuation by default
  318. // If 'true', replaces spoken punctuation with the corresponding symbols in
  319. // the request. For example, "how are you question mark" becomes "how are
  320. // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation
  321. // for support. If 'false', spoken punctuation is not replaced.
  322. google.protobuf.BoolValue enable_spoken_punctuation = 22;
  323. // The spoken emoji behavior for the call
  324. // If not set, uses default behavior based on model of choice
  325. // If 'true', adds spoken emoji formatting for the request. This will replace
  326. // spoken emojis with the corresponding Unicode symbols in the final
  327. // transcript. If 'false', spoken emojis are not replaced.
  328. google.protobuf.BoolValue enable_spoken_emojis = 23;
  329. // If 'true', enables speaker detection for each recognized word in
  330. // the top alternative of the recognition result using a speaker_tag provided
  331. // in the WordInfo.
  332. // Note: Use diarization_config instead.
  333. bool enable_speaker_diarization = 16 [deprecated = true];
  334. // If set, specifies the estimated number of speakers in the conversation.
  335. // Defaults to '2'. Ignored unless enable_speaker_diarization is set to true.
  336. // Note: Use diarization_config instead.
  337. int32 diarization_speaker_count = 17 [deprecated = true];
  338. // Config to enable speaker diarization and set additional
  339. // parameters to make diarization better suited for your application.
  340. // Note: When this is enabled, we send all the words from the beginning of the
  341. // audio for the top alternative in every consecutive STREAMING responses.
  342. // This is done in order to improve our speaker tags as our models learn to
  343. // identify the speakers in the conversation over time.
  344. // For non-streaming requests, the diarization results will be provided only
  345. // in the top alternative of the FINAL SpeechRecognitionResult.
  346. SpeakerDiarizationConfig diarization_config = 19;
  347. // Metadata regarding this request.
  348. RecognitionMetadata metadata = 9;
  349. // Which model to select for the given request. Select the model
  350. // best suited to your domain to get best results. If a model is not
  351. // explicitly specified, then we auto-select a model based on the parameters
  352. // in the RecognitionConfig.
  353. // <table>
  354. // <tr>
  355. // <td><b>Model</b></td>
  356. // <td><b>Description</b></td>
  357. // </tr>
  358. // <tr>
  359. // <td><code>latest_long</code></td>
  360. // <td>Best for long form content like media or conversation.</td>
  361. // </tr>
  362. // <tr>
  363. // <td><code>latest_short</code></td>
  364. // <td>Best for short form content like commands or single shot directed
  365. // speech.</td>
  366. // </tr>
  367. // <tr>
  368. // <td><code>command_and_search</code></td>
  369. // <td>Best for short queries such as voice commands or voice search.</td>
  370. // </tr>
  371. // <tr>
  372. // <td><code>phone_call</code></td>
  373. // <td>Best for audio that originated from a phone call (typically
  374. // recorded at an 8khz sampling rate).</td>
  375. // </tr>
  376. // <tr>
  377. // <td><code>video</code></td>
  378. // <td>Best for audio that originated from video or includes multiple
  379. // speakers. Ideally the audio is recorded at a 16khz or greater
  380. // sampling rate. This is a premium model that costs more than the
  381. // standard rate.</td>
  382. // </tr>
  383. // <tr>
  384. // <td><code>default</code></td>
  385. // <td>Best for audio that is not one of the specific audio models.
  386. // For example, long-form audio. Ideally the audio is high-fidelity,
  387. // recorded at a 16khz or greater sampling rate.</td>
  388. // </tr>
  389. // <tr>
  390. // <td><code>medical_conversation</code></td>
  391. // <td>Best for audio that originated from a conversation between a
  392. // medical provider and patient.</td>
  393. // </tr>
  394. // <tr>
  395. // <td><code>medical_dictation</code></td>
  396. // <td>Best for audio that originated from dictation notes by a medical
  397. // provider.</td>
  398. // </tr>
  399. // </table>
  400. string model = 13;
  401. // Set to true to use an enhanced model for speech recognition.
  402. // If `use_enhanced` is set to true and the `model` field is not set, then
  403. // an appropriate enhanced model is chosen if an enhanced model exists for
  404. // the audio.
  405. //
  406. // If `use_enhanced` is true and an enhanced version of the specified model
  407. // does not exist, then the speech is recognized using the standard version
  408. // of the specified model.
  409. bool use_enhanced = 14;
  410. }
  411. // Config to enable speaker diarization.
  412. message SpeakerDiarizationConfig {
  413. // If 'true', enables speaker detection for each recognized word in
  414. // the top alternative of the recognition result using a speaker_tag provided
  415. // in the WordInfo.
  416. bool enable_speaker_diarization = 1;
  417. // Minimum number of speakers in the conversation. This range gives you more
  418. // flexibility by allowing the system to automatically determine the correct
  419. // number of speakers. If not set, the default value is 2.
  420. int32 min_speaker_count = 2;
  421. // Maximum number of speakers in the conversation. This range gives you more
  422. // flexibility by allowing the system to automatically determine the correct
  423. // number of speakers. If not set, the default value is 6.
  424. int32 max_speaker_count = 3;
  425. // Output only. Unused.
  426. int32 speaker_tag = 5 [
  427. deprecated = true,
  428. (google.api.field_behavior) = OUTPUT_ONLY
  429. ];
  430. }
  431. // Description of audio data to be recognized.
  432. message RecognitionMetadata {
  433. option deprecated = true;
  434. // Use case categories that the audio recognition request can be described
  435. // by.
  436. enum InteractionType {
  437. // Use case is either unknown or is something other than one of the other
  438. // values below.
  439. INTERACTION_TYPE_UNSPECIFIED = 0;
  440. // Multiple people in a conversation or discussion. For example in a
  441. // meeting with two or more people actively participating. Typically
  442. // all the primary people speaking would be in the same room (if not,
  443. // see PHONE_CALL)
  444. DISCUSSION = 1;
  445. // One or more persons lecturing or presenting to others, mostly
  446. // uninterrupted.
  447. PRESENTATION = 2;
  448. // A phone-call or video-conference in which two or more people, who are
  449. // not in the same room, are actively participating.
  450. PHONE_CALL = 3;
  451. // A recorded message intended for another person to listen to.
  452. VOICEMAIL = 4;
  453. // Professionally produced audio (eg. TV Show, Podcast).
  454. PROFESSIONALLY_PRODUCED = 5;
  455. // Transcribe spoken questions and queries into text.
  456. VOICE_SEARCH = 6;
  457. // Transcribe voice commands, such as for controlling a device.
  458. VOICE_COMMAND = 7;
  459. // Transcribe speech to text to create a written document, such as a
  460. // text-message, email or report.
  461. DICTATION = 8;
  462. }
  463. // Enumerates the types of capture settings describing an audio file.
  464. enum MicrophoneDistance {
  465. // Audio type is not known.
  466. MICROPHONE_DISTANCE_UNSPECIFIED = 0;
  467. // The audio was captured from a closely placed microphone. Eg. phone,
  468. // dictaphone, or handheld microphone. Generally if there speaker is within
  469. // 1 meter of the microphone.
  470. NEARFIELD = 1;
  471. // The speaker if within 3 meters of the microphone.
  472. MIDFIELD = 2;
  473. // The speaker is more than 3 meters away from the microphone.
  474. FARFIELD = 3;
  475. }
  476. // The original media the speech was recorded on.
  477. enum OriginalMediaType {
  478. // Unknown original media type.
  479. ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0;
  480. // The speech data is an audio recording.
  481. AUDIO = 1;
  482. // The speech data originally recorded on a video.
  483. VIDEO = 2;
  484. }
  485. // The type of device the speech was recorded with.
  486. enum RecordingDeviceType {
  487. // The recording device is unknown.
  488. RECORDING_DEVICE_TYPE_UNSPECIFIED = 0;
  489. // Speech was recorded on a smartphone.
  490. SMARTPHONE = 1;
  491. // Speech was recorded using a personal computer or tablet.
  492. PC = 2;
  493. // Speech was recorded over a phone line.
  494. PHONE_LINE = 3;
  495. // Speech was recorded in a vehicle.
  496. VEHICLE = 4;
  497. // Speech was recorded outdoors.
  498. OTHER_OUTDOOR_DEVICE = 5;
  499. // Speech was recorded indoors.
  500. OTHER_INDOOR_DEVICE = 6;
  501. }
  502. // The use case most closely describing the audio content to be recognized.
  503. InteractionType interaction_type = 1;
  504. // The industry vertical to which this speech recognition request most
  505. // closely applies. This is most indicative of the topics contained
  506. // in the audio. Use the 6-digit NAICS code to identify the industry
  507. // vertical - see https://www.naics.com/search/.
  508. uint32 industry_naics_code_of_audio = 3;
  509. // The audio type that most closely describes the audio being recognized.
  510. MicrophoneDistance microphone_distance = 4;
  511. // The original media the speech was recorded on.
  512. OriginalMediaType original_media_type = 5;
  513. // The type of device the speech was recorded with.
  514. RecordingDeviceType recording_device_type = 6;
  515. // The device used to make the recording. Examples 'Nexus 5X' or
  516. // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or
  517. // 'Cardioid Microphone'.
  518. string recording_device_name = 7;
  519. // Mime type of the original audio file. For example `audio/m4a`,
  520. // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`.
  521. // A list of possible audio mime types is maintained at
  522. // http://www.iana.org/assignments/media-types/media-types.xhtml#audio
  523. string original_mime_type = 8;
  524. // Obfuscated (privacy-protected) ID of the user, to identify number of
  525. // unique users using the service.
  526. int64 obfuscated_id = 9 [deprecated = true];
  527. // Description of the content. Eg. "Recordings of federal supreme court
  528. // hearings from 2012".
  529. string audio_topic = 10;
  530. }
  531. // Provides "hints" to the speech recognizer to favor specific words and phrases
  532. // in the results.
  533. message SpeechContext {
  534. // A list of strings containing words and phrases "hints" so that
  535. // the speech recognition is more likely to recognize them. This can be used
  536. // to improve the accuracy for specific words and phrases, for example, if
  537. // specific commands are typically spoken by the user. This can also be used
  538. // to add additional words to the vocabulary of the recognizer. See
  539. // [usage limits](https://cloud.google.com/speech-to-text/quotas#content).
  540. //
  541. // List items can also be set to classes for groups of words that represent
  542. // common concepts that occur in natural language. For example, rather than
  543. // providing phrase hints for every month of the year, using the $MONTH class
  544. // improves the likelihood of correctly transcribing audio that includes
  545. // months.
  546. repeated string phrases = 1;
  547. // Hint Boost. Positive value will increase the probability that a specific
  548. // phrase will be recognized over other similar sounding phrases. The higher
  549. // the boost, the higher the chance of false positive recognition as well.
  550. // Negative boost values would correspond to anti-biasing. Anti-biasing is not
  551. // enabled, so negative boost will simply be ignored. Though `boost` can
  552. // accept a wide range of positive values, most use cases are best served with
  553. // values between 0 and 20. We recommend using a binary search approach to
  554. // finding the optimal value for your use case.
  555. float boost = 4;
  556. }
  557. // Contains audio data in the encoding specified in the `RecognitionConfig`.
  558. // Either `content` or `uri` must be supplied. Supplying both or neither
  559. // returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See
  560. // [content limits](https://cloud.google.com/speech-to-text/quotas#content).
  561. message RecognitionAudio {
  562. // The audio source, which is either inline content or a Google Cloud
  563. // Storage uri.
  564. oneof audio_source {
  565. // The audio data bytes encoded as specified in
  566. // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a
  567. // pure binary representation, whereas JSON representations use base64.
  568. bytes content = 1;
  569. // URI that points to a file that contains audio data bytes as specified in
  570. // `RecognitionConfig`. The file must not be compressed (for example, gzip).
  571. // Currently, only Google Cloud Storage URIs are
  572. // supported, which must be specified in the following format:
  573. // `gs://bucket_name/object_name` (other URI formats return
  574. // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see
  575. // [Request URIs](https://cloud.google.com/storage/docs/reference-uris).
  576. string uri = 2;
  577. }
  578. }
  579. // The only message returned to the client by the `Recognize` method. It
  580. // contains the result as zero or more sequential `SpeechRecognitionResult`
  581. // messages.
  582. message RecognizeResponse {
  583. // Sequential list of transcription results corresponding to
  584. // sequential portions of audio.
  585. repeated SpeechRecognitionResult results = 2;
  586. // When available, billed audio seconds for the corresponding request.
  587. google.protobuf.Duration total_billed_time = 3;
  588. }
  589. // The only message returned to the client by the `LongRunningRecognize` method.
  590. // It contains the result as zero or more sequential `SpeechRecognitionResult`
  591. // messages. It is included in the `result.response` field of the `Operation`
  592. // returned by the `GetOperation` call of the `google::longrunning::Operations`
  593. // service.
  594. message LongRunningRecognizeResponse {
  595. // Sequential list of transcription results corresponding to
  596. // sequential portions of audio.
  597. repeated SpeechRecognitionResult results = 2;
  598. // When available, billed audio seconds for the corresponding request.
  599. google.protobuf.Duration total_billed_time = 3;
  600. // Original output config if present in the request.
  601. TranscriptOutputConfig output_config = 6;
  602. // If the transcript output fails this field contains the relevant error.
  603. google.rpc.Status output_error = 7;
  604. }
  605. // Describes the progress of a long-running `LongRunningRecognize` call. It is
  606. // included in the `metadata` field of the `Operation` returned by the
  607. // `GetOperation` call of the `google::longrunning::Operations` service.
  608. message LongRunningRecognizeMetadata {
  609. // Approximate percentage of audio processed thus far. Guaranteed to be 100
  610. // when the audio is fully processed and the results are available.
  611. int32 progress_percent = 1;
  612. // Time when the request was received.
  613. google.protobuf.Timestamp start_time = 2;
  614. // Time of the most recent processing update.
  615. google.protobuf.Timestamp last_update_time = 3;
  616. // Output only. The URI of the audio file being transcribed. Empty if the audio was sent
  617. // as byte content.
  618. string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  619. // Output only. A copy of the TranscriptOutputConfig if it was set in the request.
  620. TranscriptOutputConfig output_config = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  621. }
  622. // `StreamingRecognizeResponse` is the only message returned to the client by
  623. // `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse`
  624. // messages are streamed back to the client. If there is no recognizable
  625. // audio, and `single_utterance` is set to false, then no messages are streamed
  626. // back to the client.
  627. //
  628. // Here's an example of a series of `StreamingRecognizeResponse`s that might be
  629. // returned while processing audio:
  630. //
  631. // 1. results { alternatives { transcript: "tube" } stability: 0.01 }
  632. //
  633. // 2. results { alternatives { transcript: "to be a" } stability: 0.01 }
  634. //
  635. // 3. results { alternatives { transcript: "to be" } stability: 0.9 }
  636. // results { alternatives { transcript: " or not to be" } stability: 0.01 }
  637. //
  638. // 4. results { alternatives { transcript: "to be or not to be"
  639. // confidence: 0.92 }
  640. // alternatives { transcript: "to bee or not to bee" }
  641. // is_final: true }
  642. //
  643. // 5. results { alternatives { transcript: " that's" } stability: 0.01 }
  644. //
  645. // 6. results { alternatives { transcript: " that is" } stability: 0.9 }
  646. // results { alternatives { transcript: " the question" } stability: 0.01 }
  647. //
  648. // 7. results { alternatives { transcript: " that is the question"
  649. // confidence: 0.98 }
  650. // alternatives { transcript: " that was the question" }
  651. // is_final: true }
  652. //
  653. // Notes:
  654. //
  655. // - Only two of the above responses #4 and #7 contain final results; they are
  656. // indicated by `is_final: true`. Concatenating these together generates the
  657. // full transcript: "to be or not to be that is the question".
  658. //
  659. // - The others contain interim `results`. #3 and #6 contain two interim
  660. // `results`: the first portion has a high stability and is less likely to
  661. // change; the second portion has a low stability and is very likely to
  662. // change. A UI designer might choose to show only high stability `results`.
  663. //
  664. // - The specific `stability` and `confidence` values shown above are only for
  665. // illustrative purposes. Actual values may vary.
  666. //
  667. // - In each response, only one of these fields will be set:
  668. // `error`,
  669. // `speech_event_type`, or
  670. // one or more (repeated) `results`.
  671. message StreamingRecognizeResponse {
  672. // Indicates the type of speech event.
  673. enum SpeechEventType {
  674. // No speech event specified.
  675. SPEECH_EVENT_UNSPECIFIED = 0;
  676. // This event indicates that the server has detected the end of the user's
  677. // speech utterance and expects no additional speech. Therefore, the server
  678. // will not process additional audio (although it may subsequently return
  679. // additional results). The client should stop sending additional audio
  680. // data, half-close the gRPC connection, and wait for any additional results
  681. // until the server closes the gRPC connection. This event is only sent if
  682. // `single_utterance` was set to `true`, and is not used otherwise.
  683. END_OF_SINGLE_UTTERANCE = 1;
  684. }
  685. // If set, returns a [google.rpc.Status][google.rpc.Status] message that
  686. // specifies the error for the operation.
  687. google.rpc.Status error = 1;
  688. // This repeated list contains zero or more results that
  689. // correspond to consecutive portions of the audio currently being processed.
  690. // It contains zero or one `is_final=true` result (the newly settled portion),
  691. // followed by zero or more `is_final=false` results (the interim results).
  692. repeated StreamingRecognitionResult results = 2;
  693. // Indicates the type of speech event.
  694. SpeechEventType speech_event_type = 4;
  695. // When available, billed audio seconds for the stream.
  696. // Set only if this is the last response in the stream.
  697. google.protobuf.Duration total_billed_time = 5;
  698. }
  699. // A streaming speech recognition result corresponding to a portion of the audio
  700. // that is currently being processed.
  701. message StreamingRecognitionResult {
  702. // May contain one or more recognition hypotheses (up to the
  703. // maximum specified in `max_alternatives`).
  704. // These alternatives are ordered in terms of accuracy, with the top (first)
  705. // alternative being the most probable, as ranked by the recognizer.
  706. repeated SpeechRecognitionAlternative alternatives = 1;
  707. // If `false`, this `StreamingRecognitionResult` represents an
  708. // interim result that may change. If `true`, this is the final time the
  709. // speech service will return this particular `StreamingRecognitionResult`,
  710. // the recognizer will not return any further hypotheses for this portion of
  711. // the transcript and corresponding audio.
  712. bool is_final = 2;
  713. // An estimate of the likelihood that the recognizer will not
  714. // change its guess about this interim result. Values range from 0.0
  715. // (completely unstable) to 1.0 (completely stable).
  716. // This field is only provided for interim results (`is_final=false`).
  717. // The default of 0.0 is a sentinel value indicating `stability` was not set.
  718. float stability = 3;
  719. // Time offset of the end of this result relative to the
  720. // beginning of the audio.
  721. google.protobuf.Duration result_end_time = 4;
  722. // For multi-channel audio, this is the channel number corresponding to the
  723. // recognized result for the audio from that channel.
  724. // For audio_channel_count = N, its output values can range from '1' to 'N'.
  725. int32 channel_tag = 5;
  726. // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag
  727. // of the language in this result. This language code was detected to have
  728. // the most likelihood of being spoken in the audio.
  729. string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  730. }
  731. // A speech recognition result corresponding to a portion of the audio.
  732. message SpeechRecognitionResult {
  733. // May contain one or more recognition hypotheses (up to the
  734. // maximum specified in `max_alternatives`).
  735. // These alternatives are ordered in terms of accuracy, with the top (first)
  736. // alternative being the most probable, as ranked by the recognizer.
  737. repeated SpeechRecognitionAlternative alternatives = 1;
  738. // For multi-channel audio, this is the channel number corresponding to the
  739. // recognized result for the audio from that channel.
  740. // For audio_channel_count = N, its output values can range from '1' to 'N'.
  741. int32 channel_tag = 2;
  742. // Time offset of the end of this result relative to the
  743. // beginning of the audio.
  744. google.protobuf.Duration result_end_time = 4;
  745. // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag
  746. // of the language in this result. This language code was detected to have
  747. // the most likelihood of being spoken in the audio.
  748. string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  749. }
  750. // Alternative hypotheses (a.k.a. n-best list).
  751. message SpeechRecognitionAlternative {
  752. // Transcript text representing the words that the user spoke.
  753. // In languages that use spaces to separate words, the transcript might have a
  754. // leading space if it isn't the first result. You can concatenate each result
  755. // to obtain the full transcript without using a separator.
  756. string transcript = 1;
  757. // The confidence estimate between 0.0 and 1.0. A higher number
  758. // indicates an estimated greater likelihood that the recognized words are
  759. // correct. This field is set only for the top alternative of a non-streaming
  760. // result or, of a streaming result where `is_final=true`.
  761. // This field is not guaranteed to be accurate and users should not rely on it
  762. // to be always provided.
  763. // The default of 0.0 is a sentinel value indicating `confidence` was not set.
  764. float confidence = 2;
  765. // A list of word-specific information for each recognized word.
  766. // Note: When `enable_speaker_diarization` is true, you will see all the words
  767. // from the beginning of the audio.
  768. repeated WordInfo words = 3;
  769. }
  770. // Word-specific information for recognized words.
  771. message WordInfo {
  772. // Time offset relative to the beginning of the audio,
  773. // and corresponding to the start of the spoken word.
  774. // This field is only set if `enable_word_time_offsets=true` and only
  775. // in the top hypothesis.
  776. // This is an experimental feature and the accuracy of the time offset can
  777. // vary.
  778. google.protobuf.Duration start_time = 1;
  779. // Time offset relative to the beginning of the audio,
  780. // and corresponding to the end of the spoken word.
  781. // This field is only set if `enable_word_time_offsets=true` and only
  782. // in the top hypothesis.
  783. // This is an experimental feature and the accuracy of the time offset can
  784. // vary.
  785. google.protobuf.Duration end_time = 2;
  786. // The word corresponding to this set of information.
  787. string word = 3;
  788. // The confidence estimate between 0.0 and 1.0. A higher number
  789. // indicates an estimated greater likelihood that the recognized words are
  790. // correct. This field is set only for the top alternative of a non-streaming
  791. // result or, of a streaming result where `is_final=true`.
  792. // This field is not guaranteed to be accurate and users should not rely on it
  793. // to be always provided.
  794. // The default of 0.0 is a sentinel value indicating `confidence` was not set.
  795. float confidence = 4;
  796. // Output only. A distinct integer value is assigned for every speaker within
  797. // the audio. This field specifies which one of those speakers was detected to
  798. // have spoken this word. Value ranges from '1' to diarization_speaker_count.
  799. // speaker_tag is set if enable_speaker_diarization = 'true' and only in the
  800. // top alternative.
  801. int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  802. }