> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# prompt_tts

> Play text-to-speech, then collect digits or speech.

[play-and-collect]: /docs/server-sdks/reference/python/relay/call/play-and-collect

Play text-to-speech as a prompt and collect input. A typed convenience over
[`play_and_collect()`][play-and-collect] that builds the TTS media item for you.

## Parameters

**`text`** `str` — required

The prompt to speak.

---

**`collect`** `dict` — required

Input collection configuration, in the same format as
[`play_and_collect()`][play-and-collect].

---

**`language`** `str | None` — default: None

Language code for the voice, such as `"en-US"`. Keyword-only.

---

**`gender`** `str | None` — default: None

Voice gender, `"male"` or `"female"`. Keyword-only.

---

**`voice`** `str | None` — default: None

Voice ID. Keyword-only.

---

**`volume`** `float | None` — default: None

Volume adjustment in dB, from `-40.0` to `40.0`. Keyword-only.

---

**`on_completed`** `Callable[[RelayEvent], Any] | None` — default: None

Callback invoked when the operation reaches a terminal state. Can be a regular
function or async coroutine. Keyword-only.

---

## Returns

[`CollectAction`](/docs/server-sdks/reference/python/relay/actions) -- An action handle that resolves when input is collected, the operation times out, or an error occurs.

## Example

```python {12-16}
from signalwire.relay import RelayClient

client = RelayClient(
    project="your-project-id",
    token="your-api-token",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    await call.answer()
    action = await call.prompt_tts(
        "Press 1 to book a ride or 2 to check on a booking.",
        {"digits": {"max": 1, "digit_timeout": 5}},
    )
    event = await action.wait()
    print("Collect result:", event.params)

client.run()
```