cloud_speech.proto 32 KB

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