> This page is for Server SDKs.

> 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.

# collect

> Collect DTMF or speech input without playing media.

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

[calling-call-collect]: /docs/server-sdks/reference/python/relay/call#events

[call-events]: /docs/server-sdks/reference/python/relay/call#events

[standalonecollectaction]: /docs/server-sdks/reference/python/relay/actions

Collect DTMF digit or speech input without playing a prompt. Use this when you
want to listen for input silently or after a prompt has already been played
separately. For collecting input with a prompt, use
[`play_and_collect()`][play-and-collect].

> **Info**
>
> This method emits [`calling.call.collect`][calling-call-collect] events. See [Call Events][call-events] for payload details.

## **Parameters**

**`digits`** `dict | None` — default: None

DTMF digit collection settings.

---

**`digits.max`** `int`

Maximum number of digits to collect.

---

**`digits.digit_timeout`** `float`

Seconds to wait between digits before completing.

---

**`digits.terminators`** `str`

Characters that terminate digit collection (e.g., `"#"`).

---

**`speech`** `dict | None` — default: None

Speech recognition settings.

---

**`speech.end_silence_timeout`** `float`

Seconds of silence to wait before finalizing speech input.

---

**`speech.speech_timeout`** `float`

Maximum seconds to listen for speech.

---

**`speech.language`** `str`

Speech recognition language code (e.g., `"en-US"`).

---

**`speech.hints`** `list[str]`

Words or phrases to boost recognition accuracy.

---

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

Seconds to wait for the first input before ending with `no_input`.

---

**`partial_results`** `bool | None` — default: None

Enable partial speech recognition results.

---

**`continuous`** `bool | None` — default: None

Keep collecting after each result instead of stopping.

---

**`send_start_of_input`** `bool | None` — default: None

Send an event when input is first detected.

---

**`start_input_timers`** `bool | None` — default: None

Start input timers immediately. If `False`, call
`action.start_input_timers()` to start them manually.

---

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

Custom control ID. Auto-generated if not provided.

---

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

Callback invoked when collection completes.

---

## **Returns**

[`StandaloneCollectAction`][standalonecollectaction] -- An action
handle with `stop()`, `start_input_timers()`, and `wait()` methods.

## **Example**

```python {14}
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()

    # Collect digits silently (e.g., extension entry)
    action = await call.collect(
        digits={"max": 4, "digit_timeout": 3, "terminators": "#"},
        initial_timeout=10,
    )
    event = await action.wait()

    result = event.params.get("result", {})
    extension = result.get("digits", "")
    print(f"Extension entered: {extension}")

client.run()
```