---
title: "POST /v1/speech:recognize"
method: POST
path: "/v1/speech:recognize"
tags: ["speech"]
---

# POST /v1/speech:recognize

`POST /v1/speech:recognize`

Performs synchronous speech recognition: receive results after all audio has been sent and processed.

## Request body

- RecognizeRequest — The top-level message sent by the client for the `Recognize` method.
  - `config` RecognitionConfig — Provides information to the recognizer that specifies how to process the request.
    - `speechContexts` SpeechContext[] — Array of SpeechContext. A means to provide context to assist the speech recognition. For more information, see [speech adaptation](https://cloud.google.com/speech-to-text/docs/adaptation).
      - `phrases` string[] — A list of strings containing words and phrases "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content). List items can also be set to classes for groups of words that represent common concepts that occur in natural language. For example, rather than providing phrase hints for every month of the year, using the $MONTH class improves the likelihood of correctly transcribing audio that includes months.
      - `boost` number, float — Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case.
    - `languageCode` string — Required. The language of the supplied audio as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: "en-US". See [Language Support](https://cloud.google.com/speech-to-text/docs/languages) for a list of the currently supported language codes.
    - `enableAutomaticPunctuation` boolean — If 'true', adds punctuation to recognition result hypotheses. This feature is only available in select languages. Setting this for requests in other languages has no effect at all. The default 'false' value does not add punctuation to result hypotheses.
    - `useEnhanced` boolean — Set to true to use an enhanced model for speech recognition. If `use_enhanced` is set to true and the `model` field is not set, then an appropriate enhanced model is chosen if an enhanced model exists for the audio. If `use_enhanced` is true and an enhanced version of the specified model does not exist, then the speech is recognized using the standard version of the specified model.
    - `sampleRateHertz` integer — Sample rate in Hertz of the audio data sent in all `RecognitionAudio` messages. Valid values are: 8000-48000. 16000 is optimal. For best results, set the sampling rate of the audio source to 16000 Hz. If that's not possible, use the native sample rate of the audio source (instead of re-sampling). This field is optional for FLAC and WAV audio files, but is required for all other audio formats. For details, see AudioEncoding.
    - `enableWordConfidence` boolean — If `true`, the top result includes a list of words and the confidence for those words. If `false`, no word-level confidence information is returned. The default is `false`.
    - `model` string — Which model to select for the given request. Select the model best suited to your domain to get best results. If a model is not explicitly specified, then we auto-select a model based on the parameters in the RecognitionConfig. *Model* *Description* latest_long Best for long form content like media or conversation. latest_short Best for short form content like commands or single shot directed speech. command_and_search Best for short queries such as voice commands or voice search. phone_call Best for audio that originated from a phone call (typically recorded at an 8khz sampling rate). video Best for audio that originated from video or includes multiple speakers. Ideally the audio is recorded at a 16khz or greater sampling rate. This is a premium model that costs more than the standard rate. default Best for audio that is not one of the specific audio models. For example, long-form audio. Ideally the audio is high-fidelity, recorded at a 16khz or greater sampling rate. medical_conversation Best for audio that originated from a conversation between a medical provider and patient. medical_dictation Best for audio that originated from dictation notes by a medical provider.
    - `metadata` RecognitionMetadata — Description of audio data to be recognized.
      - `interactionType` 'INTERACTION_TYPE_UNSPECIFIED' | 'DISCUSSION' | 'PRESENTATION' | 'PHONE_CALL' | 'VOICEMAIL' | 'PROFESSIONALLY_PRODUCED' | 'VOICE_SEARCH' | 'VOICE_COMMAND' | 'DICTATION' — The use case most closely describing the audio content to be recognized.
      - `recordingDeviceName` string — The device used to make the recording. Examples 'Nexus 5X' or 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or 'Cardioid Microphone'.
      - `recordingDeviceType` 'RECORDING_DEVICE_TYPE_UNSPECIFIED' | 'SMARTPHONE' | 'PC' | 'PHONE_LINE' | 'VEHICLE' | 'OTHER_OUTDOOR_DEVICE' | 'OTHER_INDOOR_DEVICE' — The type of device the speech was recorded with.
      - `microphoneDistance` 'MICROPHONE_DISTANCE_UNSPECIFIED' | 'NEARFIELD' | 'MIDFIELD' | 'FARFIELD' — The audio type that most closely describes the audio being recognized.
      - `audioTopic` string — Description of the content. Eg. "Recordings of federal supreme court hearings from 2012".
      - `industryNaicsCodeOfAudio` integer — The industry vertical to which this speech recognition request most closely applies. This is most indicative of the topics contained in the audio. Use the 6-digit NAICS code to identify the industry vertical - see https://www.naics.com/search/.
      - `originalMediaType` 'ORIGINAL_MEDIA_TYPE_UNSPECIFIED' | 'AUDIO' | 'VIDEO' — The original media the speech was recorded on.
      - `originalMimeType` string — Mime type of the original audio file. For example `audio/m4a`, `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. A list of possible audio mime types is maintained at http://www.iana.org/assignments/media-types/media-types.xhtml#audio
    - `audioChannelCount` integer — The number of channels in the input audio data. ONLY set this for MULTI-CHANNEL recognition. Valid values for LINEAR16, OGG_OPUS and FLAC are `1`-`8`. Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. If `0` or omitted, defaults to one channel (mono). Note: We only recognize the first channel by default. To perform independent recognition on each channel set `enable_separate_recognition_per_channel` to 'true'.
    - `maxAlternatives` integer — Maximum number of recognition hypotheses to be returned. Specifically, the maximum number of `SpeechRecognitionAlternative` messages within each `SpeechRecognitionResult`. The server may return fewer than `max_alternatives`. Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of one. If omitted, will return a maximum of one.
    - `encoding` 'ENCODING_UNSPECIFIED' | 'LINEAR16' | 'FLAC' | 'MULAW' | 'AMR' | 'AMR_WB' | 'OGG_OPUS' | 'SPEEX_WITH_HEADER_BYTE' | 'MP3' | 'WEBM_OPUS' | 'ALAW' — Encoding of audio data sent in all `RecognitionAudio` messages. This field is optional for `FLAC` and `WAV` audio files and required for all other audio formats. For details, see AudioEncoding.
    - `enableWordTimeOffsets` boolean — If `true`, the top result includes a list of words and the start and end time offsets (timestamps) for those words. If `false`, no word-level time offset information is returned. The default is `false`.
    - `enableSeparateRecognitionPerChannel` boolean — This needs to be set to `true` explicitly and `audio_channel_count` > 1 to get each channel recognized separately. The recognition result will contain a `channel_tag` field to state which channel that result belongs to. If this is not true, we will only recognize the first channel. The request is billed cumulatively for all channels recognized: `audio_channel_count` multiplied by the length of the audio.
    - `profanityFilter` boolean — If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. "f***". If set to `false` or omitted, profanities won't be filtered out.
    - `diarizationConfig` SpeakerDiarizationConfig — Config to enable speaker diarization.
      - `enableSpeakerDiarization` boolean — If 'true', enables speaker detection for each recognized word in the top alternative of the recognition result using a speaker_label provided in the WordInfo.
      - `minSpeakerCount` integer — Minimum number of speakers in the conversation. This range gives you more flexibility by allowing the system to automatically determine the correct number of speakers. If not set, the default value is 2.
      - `maxSpeakerCount` integer — Maximum number of speakers in the conversation. This range gives you more flexibility by allowing the system to automatically determine the correct number of speakers. If not set, the default value is 6.
      - `speakerTag` integer — Output only. Unused.
    - `adaptation` SpeechAdaptation — Speech adaptation configuration.
      - `phraseSetReferences` string[] — A collection of phrase set resource names to use.
      - `customClasses` CustomClass[] — A collection of custom classes. To specify the classes inline, leave the class' `name` blank and fill in the rest of its fields, giving it a unique `custom_class_id`. Refer to the inline defined class in phrase hints by its `custom_class_id`.
        - `deleteTime` string, google-datetime — Output only. The time at which this resource was requested for deletion. This field is not used.
        - `displayName` string — Output only. User-settable, human-readable name for the CustomClass. Must be 63 characters or less. This field is not used.
        - `items` ClassItem[] — A collection of class items.
          - `value` string — The class item's value.
        - `etag` string — Output only. This checksum is computed by the server based on the value of other fields. This may be sent on update, undelete, and delete requests to ensure the client has an up-to-date value before proceeding. This field is not used.
        - `uid` string — Output only. System-assigned unique identifier for the CustomClass. This field is not used.
        - `expireTime` string, google-datetime — Output only. The time at which this resource will be purged. This field is not used.
        - `customClassId` string — If this custom class is a resource, the custom_class_id is the resource id of the CustomClass. Case sensitive.
        - `kmsKeyVersionName` string — Output only. The [KMS key version name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with which content of the ClassItem is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
        - `kmsKeyName` string — Output only. The [KMS key name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the content of the ClassItem is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
        - `state` 'STATE_UNSPECIFIED' | 'ACTIVE' | 'DELETED' — Output only. The CustomClass lifecycle state. This field is not used.
        - `name` string — The resource name of the custom class.
        - `reconciling` boolean — Output only. Whether or not this CustomClass is in the process of being updated. This field is not used.
        - `annotations` object — Output only. Allows users to store small amounts of arbitrary data. Both the key and the value must be 63 characters or less each. At most 100 annotations. This field is not used.
      - `abnfGrammar` ABNFGrammar
        - `abnfStrings` string[] — All declarations and rules of an ABNF grammar broken up into multiple strings that will end up concatenated.
      - `phraseSets` PhraseSet[] — A collection of phrase sets. To specify the hints inline, leave the phrase set's `name` blank and fill in the rest of its fields. Any phrase set can use any custom class.
        - `annotations` object — Output only. Allows users to store small amounts of arbitrary data. Both the key and the value must be 63 characters or less each. At most 100 annotations. This field is not used.
        - `reconciling` boolean — Output only. Whether or not this PhraseSet is in the process of being updated. This field is not used.
        - `name` string — The resource name of the phrase set.
        - `kmsKeyName` string — Output only. The [KMS key name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the content of the PhraseSet is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
        - `state` 'STATE_UNSPECIFIED' | 'ACTIVE' | 'DELETED' — Output only. The CustomClass lifecycle state. This field is not used.
        - `expireTime` string, google-datetime — Output only. The time at which this resource will be purged. This field is not used.
        - `phrases` Phrase[] — A list of word and phrases.
          - `boost` number, float — Hint Boost. Overrides the boost set at the phrase set level. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case as well as adding phrases both with and without boost to your requests.
          - `value` string — The phrase itself.
        - `kmsKeyVersionName` string — Output only. The [KMS key version name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with which content of the PhraseSet is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
        - `uid` string — Output only. System-assigned unique identifier for the PhraseSet. This field is not used.
        - `boost` number, float — Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 (exclusive) and 20. We recommend using a binary search approach to finding the optimal value for your use case as well as adding phrases both with and without boost to your requests.
        - `displayName` string — Output only. User-settable, human-readable name for the PhraseSet. Must be 63 characters or less. This field is not used.
        - `etag` string — Output only. This checksum is computed by the server based on the value of other fields. This may be sent on update, undelete, and delete requests to ensure the client has an up-to-date value before proceeding. This field is not used.
        - `deleteTime` string, google-datetime — Output only. The time at which this resource was requested for deletion. This field is not used.
    - `enableSpokenEmojis` boolean — The spoken emoji behavior for the call If not set, uses default behavior based on model of choice If 'true', adds spoken emoji formatting for the request. This will replace spoken emojis with the corresponding Unicode symbols in the final transcript. If 'false', spoken emojis are not replaced.
    - `transcriptNormalization` TranscriptNormalization — Transcription normalization configuration. Use transcription normalization to automatically replace parts of the transcript with phrases of your choosing. For StreamingRecognize, this normalization only applies to stable partial transcripts (stability > 0.8) and final transcripts.
      - `entries` Entry[] — A list of replacement entries. We will perform replacement with one entry at a time. For example, the second entry in ["cat" => "dog", "mountain cat" => "mountain dog"] will never be applied because we will always process the first entry before it. At most 100 entries.
        - `search` string — What to replace. Max length is 100 characters.
        - `caseSensitive` boolean — Whether the search is case sensitive.
        - `replace` string — What to replace with. Max length is 100 characters.
    - `enableSpokenPunctuation` boolean — The spoken punctuation behavior for the call If not set, uses default behavior based on model of choice e.g. command_and_search will enable spoken punctuation by default If 'true', replaces spoken punctuation with the corresponding symbols in the request. For example, "how are you question mark" becomes "how are you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation for support. If 'false', spoken punctuation is not replaced.
    - `alternativeLanguageCodes` string[] — A list of up to 3 additional [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, listing possible alternative languages of the supplied audio. See [Language Support](https://cloud.google.com/speech-to-text/docs/languages) for a list of the currently supported language codes. If alternative languages are listed, recognition result will contain recognition in the most likely language detected including the main language_code. The recognition result will include the language tag of the language detected in the audio. Note: This feature is only supported for Voice Command and Voice Search use cases and performance may vary for other use cases (e.g., phone call transcription).
  - `audio` RecognitionAudio — Contains audio data in the encoding specified in the `RecognitionConfig`. Either `content` or `uri` must be supplied. Supplying both or neither returns google.rpc.Code.INVALID_ARGUMENT. See [content limits](https://cloud.google.com/speech-to-text/quotas#content).
    - `content` string, byte — The audio data bytes encoded as specified in `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64.
    - `uri` string — URI that points to a file that contains audio data bytes as specified in `RecognitionConfig`. The file must not be compressed (for example, gzip). Currently, only Google Cloud Storage URIs are supported, which must be specified in the following format: `gs://bucket_name/object_name` (other URI formats return google.rpc.Code.INVALID_ARGUMENT). For more information, see [Request URIs](https://cloud.google.com/storage/docs/reference-uris).

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/speech.md) · [All operations](https://skmtc.dev/google/apis/speech/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/speech/revisions/11b892dab9f9/schema)
