cloud_speech.proto 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  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.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/cloud/speech/v1/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/v1;speech";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "SpeechProto";
  29. option java_package = "com.google.cloud.speech.v1";
  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: "/v1/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: "/v1/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. // Opus encoded audio frames in WebM container
  214. // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be
  215. // one of 8000, 12000, 16000, 24000, or 48000.
  216. WEBM_OPUS = 9;
  217. }
  218. // Encoding of audio data sent in all `RecognitionAudio` messages.
  219. // This field is optional for `FLAC` and `WAV` audio files and required
  220. // for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding].
  221. AudioEncoding encoding = 1;
  222. // Sample rate in Hertz of the audio data sent in all
  223. // `RecognitionAudio` messages. Valid values are: 8000-48000.
  224. // 16000 is optimal. For best results, set the sampling rate of the audio
  225. // source to 16000 Hz. If that's not possible, use the native sample rate of
  226. // the audio source (instead of re-sampling).
  227. // This field is optional for FLAC and WAV audio files, but is
  228. // required for all other audio formats. For details, see [AudioEncoding][google.cloud.speech.v1.RecognitionConfig.AudioEncoding].
  229. int32 sample_rate_hertz = 2;
  230. // The number of channels in the input audio data.
  231. // ONLY set this for MULTI-CHANNEL recognition.
  232. // Valid values for LINEAR16 and FLAC are `1`-`8`.
  233. // Valid values for OGG_OPUS are '1'-'254'.
  234. // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`.
  235. // If `0` or omitted, defaults to one channel (mono).
  236. // Note: We only recognize the first channel by default.
  237. // To perform independent recognition on each channel set
  238. // `enable_separate_recognition_per_channel` to 'true'.
  239. int32 audio_channel_count = 7;
  240. // This needs to be set to `true` explicitly and `audio_channel_count` > 1
  241. // to get each channel recognized separately. The recognition result will
  242. // contain a `channel_tag` field to state which channel that result belongs
  243. // to. If this is not true, we will only recognize the first channel. The
  244. // request is billed cumulatively for all channels recognized:
  245. // `audio_channel_count` multiplied by the length of the audio.
  246. bool enable_separate_recognition_per_channel = 12;
  247. // Required. The language of the supplied audio as a
  248. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
  249. // Example: "en-US".
  250. // See [Language
  251. // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list
  252. // of the currently supported language codes.
  253. string language_code = 3 [(google.api.field_behavior) = REQUIRED];
  254. // A list of up to 3 additional
  255. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags,
  256. // listing possible alternative languages of the supplied audio.
  257. // See [Language
  258. // Support](https://cloud.google.com/speech-to-text/docs/languages) for a list
  259. // of the currently supported language codes. If alternative languages are
  260. // listed, recognition result will contain recognition in the most likely
  261. // language detected including the main language_code. The recognition result
  262. // will include the language tag of the language detected in the audio. Note:
  263. // This feature is only supported for Voice Command and Voice Search use cases
  264. // and performance may vary for other use cases (e.g., phone call
  265. // transcription).
  266. repeated string alternative_language_codes = 18;
  267. // Maximum number of recognition hypotheses to be returned.
  268. // Specifically, the maximum number of `SpeechRecognitionAlternative` messages
  269. // within each `SpeechRecognitionResult`.
  270. // The server may return fewer than `max_alternatives`.
  271. // Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of
  272. // one. If omitted, will return a maximum of one.
  273. int32 max_alternatives = 4;
  274. // If set to `true`, the server will attempt to filter out
  275. // profanities, replacing all but the initial character in each filtered word
  276. // with asterisks, e.g. "f***". If set to `false` or omitted, profanities
  277. // won't be filtered out.
  278. bool profanity_filter = 5;
  279. // Speech adaptation configuration improves the accuracy of speech
  280. // recognition. For more information, see the [speech
  281. // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation)
  282. // documentation.
  283. // When speech adaptation is set it supersedes the `speech_contexts` field.
  284. SpeechAdaptation adaptation = 20;
  285. // Array of [SpeechContext][google.cloud.speech.v1.SpeechContext].
  286. // A means to provide context to assist the speech recognition. For more
  287. // information, see
  288. // [speech
  289. // adaptation](https://cloud.google.com/speech-to-text/docs/adaptation).
  290. repeated SpeechContext speech_contexts = 6;
  291. // If `true`, the top result includes a list of words and
  292. // the start and end time offsets (timestamps) for those words. If
  293. // `false`, no word-level time offset information is returned. The default is
  294. // `false`.
  295. bool enable_word_time_offsets = 8;
  296. // If `true`, the top result includes a list of words and the
  297. // confidence for those words. If `false`, no word-level confidence
  298. // information is returned. The default is `false`.
  299. bool enable_word_confidence = 15;
  300. // If 'true', adds punctuation to recognition result hypotheses.
  301. // This feature is only available in select languages. Setting this for
  302. // requests in other languages has no effect at all.
  303. // The default 'false' value does not add punctuation to result hypotheses.
  304. bool enable_automatic_punctuation = 11;
  305. // The spoken punctuation behavior for the call
  306. // If not set, uses default behavior based on model of choice
  307. // e.g. command_and_search will enable spoken punctuation by default
  308. // If 'true', replaces spoken punctuation with the corresponding symbols in
  309. // the request. For example, "how are you question mark" becomes "how are
  310. // you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation
  311. // for support. If 'false', spoken punctuation is not replaced.
  312. google.protobuf.BoolValue enable_spoken_punctuation = 22;
  313. // The spoken emoji behavior for the call
  314. // If not set, uses default behavior based on model of choice
  315. // If 'true', adds spoken emoji formatting for the request. This will replace
  316. // spoken emojis with the corresponding Unicode symbols in the final
  317. // transcript. If 'false', spoken emojis are not replaced.
  318. google.protobuf.BoolValue enable_spoken_emojis = 23;
  319. // Config to enable speaker diarization and set additional
  320. // parameters to make diarization better suited for your application.
  321. // Note: When this is enabled, we send all the words from the beginning of the
  322. // audio for the top alternative in every consecutive STREAMING responses.
  323. // This is done in order to improve our speaker tags as our models learn to
  324. // identify the speakers in the conversation over time.
  325. // For non-streaming requests, the diarization results will be provided only
  326. // in the top alternative of the FINAL SpeechRecognitionResult.
  327. SpeakerDiarizationConfig diarization_config = 19;
  328. // Metadata regarding this request.
  329. RecognitionMetadata metadata = 9;
  330. // Which model to select for the given request. Select the model
  331. // best suited to your domain to get best results. If a model is not
  332. // explicitly specified, then we auto-select a model based on the parameters
  333. // in the RecognitionConfig.
  334. // <table>
  335. // <tr>
  336. // <td><b>Model</b></td>
  337. // <td><b>Description</b></td>
  338. // </tr>
  339. // <tr>
  340. // <td><code>latest_long</code></td>
  341. // <td>Best for long form content like media or conversation.</td>
  342. // </tr>
  343. // <tr>
  344. // <td><code>latest_short</code></td>
  345. // <td>Best for short form content like commands or single shot directed
  346. // speech.</td>
  347. // </tr>
  348. // <tr>
  349. // <td><code>command_and_search</code></td>
  350. // <td>Best for short queries such as voice commands or voice search.</td>
  351. // </tr>
  352. // <tr>
  353. // <td><code>phone_call</code></td>
  354. // <td>Best for audio that originated from a phone call (typically
  355. // recorded at an 8khz sampling rate).</td>
  356. // </tr>
  357. // <tr>
  358. // <td><code>video</code></td>
  359. // <td>Best for audio that originated from video or includes multiple
  360. // speakers. Ideally the audio is recorded at a 16khz or greater
  361. // sampling rate. This is a premium model that costs more than the
  362. // standard rate.</td>
  363. // </tr>
  364. // <tr>
  365. // <td><code>default</code></td>
  366. // <td>Best for audio that is not one of the specific audio models.
  367. // For example, long-form audio. Ideally the audio is high-fidelity,
  368. // recorded at a 16khz or greater sampling rate.</td>
  369. // </tr>
  370. // <tr>
  371. // <td><code>medical_conversation</code></td>
  372. // <td>Best for audio that originated from a conversation between a
  373. // medical provider and patient.</td>
  374. // </tr>
  375. // <tr>
  376. // <td><code>medical_dictation</code></td>
  377. // <td>Best for audio that originated from dictation notes by a medical
  378. // provider.</td>
  379. // </tr>
  380. // </table>
  381. string model = 13;
  382. // Set to true to use an enhanced model for speech recognition.
  383. // If `use_enhanced` is set to true and the `model` field is not set, then
  384. // an appropriate enhanced model is chosen if an enhanced model exists for
  385. // the audio.
  386. //
  387. // If `use_enhanced` is true and an enhanced version of the specified model
  388. // does not exist, then the speech is recognized using the standard version
  389. // of the specified model.
  390. bool use_enhanced = 14;
  391. }
  392. // Config to enable speaker diarization.
  393. message SpeakerDiarizationConfig {
  394. // If 'true', enables speaker detection for each recognized word in
  395. // the top alternative of the recognition result using a speaker_tag provided
  396. // in the WordInfo.
  397. bool enable_speaker_diarization = 1;
  398. // Minimum number of speakers in the conversation. This range gives you more
  399. // flexibility by allowing the system to automatically determine the correct
  400. // number of speakers. If not set, the default value is 2.
  401. int32 min_speaker_count = 2;
  402. // Maximum number of speakers in the conversation. This range gives you more
  403. // flexibility by allowing the system to automatically determine the correct
  404. // number of speakers. If not set, the default value is 6.
  405. int32 max_speaker_count = 3;
  406. // Output only. Unused.
  407. int32 speaker_tag = 5 [
  408. deprecated = true,
  409. (google.api.field_behavior) = OUTPUT_ONLY
  410. ];
  411. }
  412. // Description of audio data to be recognized.
  413. message RecognitionMetadata {
  414. option deprecated = true;
  415. // Use case categories that the audio recognition request can be described
  416. // by.
  417. enum InteractionType {
  418. // Use case is either unknown or is something other than one of the other
  419. // values below.
  420. INTERACTION_TYPE_UNSPECIFIED = 0;
  421. // Multiple people in a conversation or discussion. For example in a
  422. // meeting with two or more people actively participating. Typically
  423. // all the primary people speaking would be in the same room (if not,
  424. // see PHONE_CALL)
  425. DISCUSSION = 1;
  426. // One or more persons lecturing or presenting to others, mostly
  427. // uninterrupted.
  428. PRESENTATION = 2;
  429. // A phone-call or video-conference in which two or more people, who are
  430. // not in the same room, are actively participating.
  431. PHONE_CALL = 3;
  432. // A recorded message intended for another person to listen to.
  433. VOICEMAIL = 4;
  434. // Professionally produced audio (eg. TV Show, Podcast).
  435. PROFESSIONALLY_PRODUCED = 5;
  436. // Transcribe spoken questions and queries into text.
  437. VOICE_SEARCH = 6;
  438. // Transcribe voice commands, such as for controlling a device.
  439. VOICE_COMMAND = 7;
  440. // Transcribe speech to text to create a written document, such as a
  441. // text-message, email or report.
  442. DICTATION = 8;
  443. }
  444. // Enumerates the types of capture settings describing an audio file.
  445. enum MicrophoneDistance {
  446. // Audio type is not known.
  447. MICROPHONE_DISTANCE_UNSPECIFIED = 0;
  448. // The audio was captured from a closely placed microphone. Eg. phone,
  449. // dictaphone, or handheld microphone. Generally if there speaker is within
  450. // 1 meter of the microphone.
  451. NEARFIELD = 1;
  452. // The speaker if within 3 meters of the microphone.
  453. MIDFIELD = 2;
  454. // The speaker is more than 3 meters away from the microphone.
  455. FARFIELD = 3;
  456. }
  457. // The original media the speech was recorded on.
  458. enum OriginalMediaType {
  459. // Unknown original media type.
  460. ORIGINAL_MEDIA_TYPE_UNSPECIFIED = 0;
  461. // The speech data is an audio recording.
  462. AUDIO = 1;
  463. // The speech data originally recorded on a video.
  464. VIDEO = 2;
  465. }
  466. // The type of device the speech was recorded with.
  467. enum RecordingDeviceType {
  468. // The recording device is unknown.
  469. RECORDING_DEVICE_TYPE_UNSPECIFIED = 0;
  470. // Speech was recorded on a smartphone.
  471. SMARTPHONE = 1;
  472. // Speech was recorded using a personal computer or tablet.
  473. PC = 2;
  474. // Speech was recorded over a phone line.
  475. PHONE_LINE = 3;
  476. // Speech was recorded in a vehicle.
  477. VEHICLE = 4;
  478. // Speech was recorded outdoors.
  479. OTHER_OUTDOOR_DEVICE = 5;
  480. // Speech was recorded indoors.
  481. OTHER_INDOOR_DEVICE = 6;
  482. }
  483. // The use case most closely describing the audio content to be recognized.
  484. InteractionType interaction_type = 1;
  485. // The industry vertical to which this speech recognition request most
  486. // closely applies. This is most indicative of the topics contained
  487. // in the audio. Use the 6-digit NAICS code to identify the industry
  488. // vertical - see https://www.naics.com/search/.
  489. uint32 industry_naics_code_of_audio = 3;
  490. // The audio type that most closely describes the audio being recognized.
  491. MicrophoneDistance microphone_distance = 4;
  492. // The original media the speech was recorded on.
  493. OriginalMediaType original_media_type = 5;
  494. // The type of device the speech was recorded with.
  495. RecordingDeviceType recording_device_type = 6;
  496. // The device used to make the recording. Examples 'Nexus 5X' or
  497. // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or
  498. // 'Cardioid Microphone'.
  499. string recording_device_name = 7;
  500. // Mime type of the original audio file. For example `audio/m4a`,
  501. // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`.
  502. // A list of possible audio mime types is maintained at
  503. // http://www.iana.org/assignments/media-types/media-types.xhtml#audio
  504. string original_mime_type = 8;
  505. // Description of the content. Eg. "Recordings of federal supreme court
  506. // hearings from 2012".
  507. string audio_topic = 10;
  508. }
  509. // Provides "hints" to the speech recognizer to favor specific words and phrases
  510. // in the results.
  511. message SpeechContext {
  512. // A list of strings containing words and phrases "hints" so that
  513. // the speech recognition is more likely to recognize them. This can be used
  514. // to improve the accuracy for specific words and phrases, for example, if
  515. // specific commands are typically spoken by the user. This can also be used
  516. // to add additional words to the vocabulary of the recognizer. See
  517. // [usage limits](https://cloud.google.com/speech-to-text/quotas#content).
  518. //
  519. // List items can also be set to classes for groups of words that represent
  520. // common concepts that occur in natural language. For example, rather than
  521. // providing phrase hints for every month of the year, using the $MONTH class
  522. // improves the likelihood of correctly transcribing audio that includes
  523. // months.
  524. repeated string phrases = 1;
  525. // Hint Boost. Positive value will increase the probability that a specific
  526. // phrase will be recognized over other similar sounding phrases. The higher
  527. // the boost, the higher the chance of false positive recognition as well.
  528. // Negative boost values would correspond to anti-biasing. Anti-biasing is not
  529. // enabled, so negative boost will simply be ignored. Though `boost` can
  530. // accept a wide range of positive values, most use cases are best served with
  531. // values between 0 and 20. We recommend using a binary search approach to
  532. // finding the optimal value for your use case.
  533. float boost = 4;
  534. }
  535. // Contains audio data in the encoding specified in the `RecognitionConfig`.
  536. // Either `content` or `uri` must be supplied. Supplying both or neither
  537. // returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See
  538. // [content limits](https://cloud.google.com/speech-to-text/quotas#content).
  539. message RecognitionAudio {
  540. // The audio source, which is either inline content or a Google Cloud
  541. // Storage uri.
  542. oneof audio_source {
  543. // The audio data bytes encoded as specified in
  544. // `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a
  545. // pure binary representation, whereas JSON representations use base64.
  546. bytes content = 1;
  547. // URI that points to a file that contains audio data bytes as specified in
  548. // `RecognitionConfig`. The file must not be compressed (for example, gzip).
  549. // Currently, only Google Cloud Storage URIs are
  550. // supported, which must be specified in the following format:
  551. // `gs://bucket_name/object_name` (other URI formats return
  552. // [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see
  553. // [Request URIs](https://cloud.google.com/storage/docs/reference-uris).
  554. string uri = 2;
  555. }
  556. }
  557. // The only message returned to the client by the `Recognize` method. It
  558. // contains the result as zero or more sequential `SpeechRecognitionResult`
  559. // messages.
  560. message RecognizeResponse {
  561. // Sequential list of transcription results corresponding to
  562. // sequential portions of audio.
  563. repeated SpeechRecognitionResult results = 2;
  564. // When available, billed audio seconds for the corresponding request.
  565. google.protobuf.Duration total_billed_time = 3;
  566. }
  567. // The only message returned to the client by the `LongRunningRecognize` method.
  568. // It contains the result as zero or more sequential `SpeechRecognitionResult`
  569. // messages. It is included in the `result.response` field of the `Operation`
  570. // returned by the `GetOperation` call of the `google::longrunning::Operations`
  571. // service.
  572. message LongRunningRecognizeResponse {
  573. // Sequential list of transcription results corresponding to
  574. // sequential portions of audio.
  575. repeated SpeechRecognitionResult results = 2;
  576. // When available, billed audio seconds for the corresponding request.
  577. google.protobuf.Duration total_billed_time = 3;
  578. // Original output config if present in the request.
  579. TranscriptOutputConfig output_config = 6;
  580. // If the transcript output fails this field contains the relevant error.
  581. google.rpc.Status output_error = 7;
  582. }
  583. // Describes the progress of a long-running `LongRunningRecognize` call. It is
  584. // included in the `metadata` field of the `Operation` returned by the
  585. // `GetOperation` call of the `google::longrunning::Operations` service.
  586. message LongRunningRecognizeMetadata {
  587. // Approximate percentage of audio processed thus far. Guaranteed to be 100
  588. // when the audio is fully processed and the results are available.
  589. int32 progress_percent = 1;
  590. // Time when the request was received.
  591. google.protobuf.Timestamp start_time = 2;
  592. // Time of the most recent processing update.
  593. google.protobuf.Timestamp last_update_time = 3;
  594. // Output only. The URI of the audio file being transcribed. Empty if the audio was sent
  595. // as byte content.
  596. string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  597. }
  598. // `StreamingRecognizeResponse` is the only message returned to the client by
  599. // `StreamingRecognize`. A series of zero or more `StreamingRecognizeResponse`
  600. // messages are streamed back to the client. If there is no recognizable
  601. // audio, and `single_utterance` is set to false, then no messages are streamed
  602. // back to the client.
  603. //
  604. // Here's an example of a series of `StreamingRecognizeResponse`s that might be
  605. // returned while processing audio:
  606. //
  607. // 1. results { alternatives { transcript: "tube" } stability: 0.01 }
  608. //
  609. // 2. results { alternatives { transcript: "to be a" } stability: 0.01 }
  610. //
  611. // 3. results { alternatives { transcript: "to be" } stability: 0.9 }
  612. // results { alternatives { transcript: " or not to be" } stability: 0.01 }
  613. //
  614. // 4. results { alternatives { transcript: "to be or not to be"
  615. // confidence: 0.92 }
  616. // alternatives { transcript: "to bee or not to bee" }
  617. // is_final: true }
  618. //
  619. // 5. results { alternatives { transcript: " that's" } stability: 0.01 }
  620. //
  621. // 6. results { alternatives { transcript: " that is" } stability: 0.9 }
  622. // results { alternatives { transcript: " the question" } stability: 0.01 }
  623. //
  624. // 7. results { alternatives { transcript: " that is the question"
  625. // confidence: 0.98 }
  626. // alternatives { transcript: " that was the question" }
  627. // is_final: true }
  628. //
  629. // Notes:
  630. //
  631. // - Only two of the above responses #4 and #7 contain final results; they are
  632. // indicated by `is_final: true`. Concatenating these together generates the
  633. // full transcript: "to be or not to be that is the question".
  634. //
  635. // - The others contain interim `results`. #3 and #6 contain two interim
  636. // `results`: the first portion has a high stability and is less likely to
  637. // change; the second portion has a low stability and is very likely to
  638. // change. A UI designer might choose to show only high stability `results`.
  639. //
  640. // - The specific `stability` and `confidence` values shown above are only for
  641. // illustrative purposes. Actual values may vary.
  642. //
  643. // - In each response, only one of these fields will be set:
  644. // `error`,
  645. // `speech_event_type`, or
  646. // one or more (repeated) `results`.
  647. message StreamingRecognizeResponse {
  648. // Indicates the type of speech event.
  649. enum SpeechEventType {
  650. // No speech event specified.
  651. SPEECH_EVENT_UNSPECIFIED = 0;
  652. // This event indicates that the server has detected the end of the user's
  653. // speech utterance and expects no additional speech. Therefore, the server
  654. // will not process additional audio (although it may subsequently return
  655. // additional results). The client should stop sending additional audio
  656. // data, half-close the gRPC connection, and wait for any additional results
  657. // until the server closes the gRPC connection. This event is only sent if
  658. // `single_utterance` was set to `true`, and is not used otherwise.
  659. END_OF_SINGLE_UTTERANCE = 1;
  660. }
  661. // If set, returns a [google.rpc.Status][google.rpc.Status] message that
  662. // specifies the error for the operation.
  663. google.rpc.Status error = 1;
  664. // This repeated list contains zero or more results that
  665. // correspond to consecutive portions of the audio currently being processed.
  666. // It contains zero or one `is_final=true` result (the newly settled portion),
  667. // followed by zero or more `is_final=false` results (the interim results).
  668. repeated StreamingRecognitionResult results = 2;
  669. // Indicates the type of speech event.
  670. SpeechEventType speech_event_type = 4;
  671. // When available, billed audio seconds for the stream.
  672. // Set only if this is the last response in the stream.
  673. google.protobuf.Duration total_billed_time = 5;
  674. }
  675. // A streaming speech recognition result corresponding to a portion of the audio
  676. // that is currently being processed.
  677. message StreamingRecognitionResult {
  678. // May contain one or more recognition hypotheses (up to the
  679. // maximum specified in `max_alternatives`).
  680. // These alternatives are ordered in terms of accuracy, with the top (first)
  681. // alternative being the most probable, as ranked by the recognizer.
  682. repeated SpeechRecognitionAlternative alternatives = 1;
  683. // If `false`, this `StreamingRecognitionResult` represents an
  684. // interim result that may change. If `true`, this is the final time the
  685. // speech service will return this particular `StreamingRecognitionResult`,
  686. // the recognizer will not return any further hypotheses for this portion of
  687. // the transcript and corresponding audio.
  688. bool is_final = 2;
  689. // An estimate of the likelihood that the recognizer will not
  690. // change its guess about this interim result. Values range from 0.0
  691. // (completely unstable) to 1.0 (completely stable).
  692. // This field is only provided for interim results (`is_final=false`).
  693. // The default of 0.0 is a sentinel value indicating `stability` was not set.
  694. float stability = 3;
  695. // Time offset of the end of this result relative to the
  696. // beginning of the audio.
  697. google.protobuf.Duration result_end_time = 4;
  698. // For multi-channel audio, this is the channel number corresponding to the
  699. // recognized result for the audio from that channel.
  700. // For audio_channel_count = N, its output values can range from '1' to 'N'.
  701. int32 channel_tag = 5;
  702. // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag
  703. // of the language in this result. This language code was detected to have
  704. // the most likelihood of being spoken in the audio.
  705. string language_code = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  706. }
  707. // A speech recognition result corresponding to a portion of the audio.
  708. message SpeechRecognitionResult {
  709. // May contain one or more recognition hypotheses (up to the
  710. // maximum specified in `max_alternatives`).
  711. // These alternatives are ordered in terms of accuracy, with the top (first)
  712. // alternative being the most probable, as ranked by the recognizer.
  713. repeated SpeechRecognitionAlternative alternatives = 1;
  714. // For multi-channel audio, this is the channel number corresponding to the
  715. // recognized result for the audio from that channel.
  716. // For audio_channel_count = N, its output values can range from '1' to 'N'.
  717. int32 channel_tag = 2;
  718. // Time offset of the end of this result relative to the
  719. // beginning of the audio.
  720. google.protobuf.Duration result_end_time = 4;
  721. // Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag
  722. // of the language in this result. This language code was detected to have
  723. // the most likelihood of being spoken in the audio.
  724. string language_code = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  725. }
  726. // Alternative hypotheses (a.k.a. n-best list).
  727. message SpeechRecognitionAlternative {
  728. // Transcript text representing the words that the user spoke.
  729. // In languages that use spaces to separate words, the transcript might have a
  730. // leading space if it isn't the first result. You can concatenate each result
  731. // to obtain the full transcript without using a separator.
  732. string transcript = 1;
  733. // The confidence estimate between 0.0 and 1.0. A higher number
  734. // indicates an estimated greater likelihood that the recognized words are
  735. // correct. This field is set only for the top alternative of a non-streaming
  736. // result or, of a streaming result where `is_final=true`.
  737. // This field is not guaranteed to be accurate and users should not rely on it
  738. // to be always provided.
  739. // The default of 0.0 is a sentinel value indicating `confidence` was not set.
  740. float confidence = 2;
  741. // A list of word-specific information for each recognized word.
  742. // Note: When `enable_speaker_diarization` is true, you will see all the words
  743. // from the beginning of the audio.
  744. repeated WordInfo words = 3;
  745. }
  746. // Word-specific information for recognized words.
  747. message WordInfo {
  748. // Time offset relative to the beginning of the audio,
  749. // and corresponding to the start of the spoken word.
  750. // This field is only set if `enable_word_time_offsets=true` and only
  751. // in the top hypothesis.
  752. // This is an experimental feature and the accuracy of the time offset can
  753. // vary.
  754. google.protobuf.Duration start_time = 1;
  755. // Time offset relative to the beginning of the audio,
  756. // and corresponding to the end of the spoken word.
  757. // This field is only set if `enable_word_time_offsets=true` and only
  758. // in the top hypothesis.
  759. // This is an experimental feature and the accuracy of the time offset can
  760. // vary.
  761. google.protobuf.Duration end_time = 2;
  762. // The word corresponding to this set of information.
  763. string word = 3;
  764. // The confidence estimate between 0.0 and 1.0. A higher number
  765. // indicates an estimated greater likelihood that the recognized words are
  766. // correct. This field is set only for the top alternative of a non-streaming
  767. // result or, of a streaming result where `is_final=true`.
  768. // This field is not guaranteed to be accurate and users should not rely on it
  769. // to be always provided.
  770. // The default of 0.0 is a sentinel value indicating `confidence` was not set.
  771. float confidence = 4;
  772. // Output only. A distinct integer value is assigned for every speaker within
  773. // the audio. This field specifies which one of those speakers was detected to
  774. // have spoken this word. Value ranges from '1' to diarization_speaker_count.
  775. // speaker_tag is set if enable_speaker_diarization = 'true' and only in the
  776. // top alternative.
  777. int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  778. }