> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developers.deepgram.com/docs/tts-sample-rate/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.deepgram.com/_mcp/server. # Sample Rate `sample_rate` *string* Text to Speech Request Text to Speech Stream English Only The Sample Rate feature allows users to specify the desired sample rate of the resulting text-to-speech audio output. Sample rate refers to the number of samples of audio carried per second, measured in Hertz (Hz). Choosing the appropriate sample rate is crucial as it directly impacts the audio quality and file size of the output. Higher sample rates typically result in better audio quality but may increase the file size, while lower sample rates may reduce file size but can compromise audio fidelity. > **Warning** > > The `sample_rate` value must adhere to the [Audio Format Combinations table](/docs/tts-media-output-settings#audio-format-combinations). Choose a value based on the encoding type and your use case. Based on encoding `8000` or `24000`are possible defaults. For some encodings sample rate is not configurable. ## Enable Feature To enable the Sample Rate feature, include the `sample_rate` parameter in the query string with the desired sample rate value. You can use the following cURL command in a terminal or your favorite API client to synthesize text into speech with a specific sample rate. **Sample rate of 24 kHz**: **`cURL`** ```bash cURL curl --request POST \ --url "https://api.deepgram.com/v1/speak?model=aura-2-thalia-en&encoding=linear16&sample_rate=24000" \ --header "Authorization: Token DEEPGRAM_API_KEY" \ --header 'Content-Type: application/json' \ --data '{"text": "Hello, how can I help you today?"}' \ --output sample_rate_24000.wav \ --fail-with-body \ --silent || echo "Request failed" ``` > **Warning** > > Replace `YOUR_DEEPGRAM_API_KEY` with your [Deepgram API Key](/docs/create-additional-api-keys). ### Query Parameters | Parameter | Value | Type | Description | | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------- | | `sample_rate` | See list of supported audio format combinations in the [Audio Format Combinations table](/docs/tts-media-output-settings#audio-format-combinations). | `string` | The desired sample rate for the output audio. | ## Analyze Response Upon successful processing of the request, you will receive an audio file containing the synthesized text-to-speech output, along with response headers providing additional information. > **Info** > > The audio file is streamed back to you, so you may begin playback as soon as the first byte arrives. Read the guide [Streaming Audio Outputs](/docs/streaming-the-audio-output) to learn how to begin playing the stream immediately versus waiting for the entire file to arrive. ### Response Headers Example **`http`** ```text http HTTP/1.1 200 OK < content-type: audio/mpeg < dg-model-name: aura-2-thalia-en < dg-model-uuid: e4979ab0-8475-4901-9d66-0a562a4949bb < dg-char-count: 32 < dg-request-id: bf6fc5c7-8f84-479f-b70a-602cf5bf18f3 < transfer-encoding: chunked < date: Thu, 29 Feb 2024 19:20:48 GMT ``` > **Info** > > To see these response headers when making a CURL request, add `-v` or `--verbose` to your request. This includes: * `content-type`: Specifies the media type of the resource, in this case, `audio/mpeg`, indicating the format of the audio file returned. * `dg-request-id`: A unique identifier for the request, useful for debugging and tracking purposes. * `dg-model-uuid`: The unique identifier of the model that processed the request. * `dg-char-count`: Indicates the number of characters that were in the input text for the text-to-speech process. * `dg-model-name`: The name of the model used to process the request. * `transfer-encoding`: Specifies the form of encoding used to safely transfer the payload to the recipient. * `date`: The date and time the response was sent. > Sample Rate specifies the sample rate for the output audio.