This page shows you how to send a speech recognition request to Speech-to-Text
using the [REST interface](https://docs.cloud.google.com/speech-to-text/docs/reference/rest.md.txt) and the `curl` command.


Speech-to-Text enables easy integration of Google speech
recognition technologies into developer applications. You can send
audio data to the Speech-to-Text API, which then returns a
text transcription of that audio file. For more information about
the service, see
[Cloud STT basics](https://docs.cloud.google.com/speech-to-text/docs/basics).

## Before you begin

## Make an audio transcription request

Use the following code sample to send a [`recognize`](https://docs.cloud.google.com/speech-to-text/docs/reference/rest/v2/projects.locations.recognizers/recognize.md.txt) REST
request to the Speech-to-Text API.

1. Run this command to create a JSON file as input for the request. Replace
   `/full/path/to/audio/file.wav` with the path to the audio
   file you want to transcribe:

   <br />

   ```bash
   echo "{
     \"config\": {
       \"auto_decoding_config\": {},
       \"language_codes\": [\"en-US\"],
       \"model\": \"long\"
     },
     \"content\": \"$(base64 -w 0 /full/path/to/audio/file.wav | sed 's/+/-/g; s/\//_/g')\"
   }" > /tmp/data.txt
   ```
2. Use `curl` to make a `recognize` request:

   <br />

   ```bash
   curl -X POST -H "Content-Type: application/json; charset=utf-8" \
       -H "Authorization: Bearer $(gcloud auth print-access-token)" \
       -d @/tmp/data.txt \
       https://speech.googleapis.com/v2/projects/PROJECT_ID/locations/global/recognizers/_:recognize
   ```

   > [!NOTE]
   > **Note:** To pass a filename to `curl`, you use the `-d` option (for "data") and precede the filename with an `@` sign.

   You should see a response similar to the following:

   ```json
     {
       "results": [
         {
           "alternatives": [
             {
               "transcript": "how old is the Brooklyn Bridge",
               "confidence": 0.98267895
             }
           ]
         }
       ]
     }
   ```

You sent your first request to Speech-to-Text.

## Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

1.
   Optional: Revoke the authentication credentials that you created, and delete the local
   credential file.

   ```bash
   gcloud auth application-default revoke
   ```
2.
   Optional: Revoke credentials from the gcloud CLI.

   ```bash
   gcloud auth revoke
   ```

### Console


> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

- In the Google Cloud console, go to the **Manage resources** page.

  [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
- In the project list, select the project that you want to delete, and then click **Delete**.
- In the dialog, type the project ID, and then click **Shut down** to delete the project.

### gcloud


> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

Delete a Google Cloud project:

```
gcloud projects delete PROJECT_ID
```

<br />

## What's next

- Use [client libraries](https://docs.cloud.google.com/speech-to-text/docs/client-libraries) to transcribe audio using your favorite programming language.
- Learn how to [transcribe short audio files](https://docs.cloud.google.com/speech-to-text/docs/sync-recognize.md.txt).
- Learn how to [transcribe streaming audio](https://docs.cloud.google.com/speech-to-text/docs/streaming-recognize.md.txt).
- Learn how to [transcribe long audio files](https://docs.cloud.google.com/speech-to-text/docs/batch-recognize.md.txt).
- For best performance, accuracy, and other tips, see the [best practices](https://docs.cloud.google.com/speech-to-text/docs/best-practices.md.txt) documentation.