Skip to content

[Enhancement] Add streaming session mute/unmute helpers for pause and resume #717

@deepgram-robot

Description

@deepgram-robot

Summary

Add mute() and unmute() convenience methods to the streaming WebSocket clients (ListenWebSocketClient and AsyncListenWebSocketClient) that pause audio transmission while keeping the connection alive, without requiring developers to manually manage KeepAlive timers.

Problem it solves

Developers building voice applications frequently need to pause transcription (e.g., when the user clicks a mute button, during hold music, or when switching audio sources) without tearing down and re-establishing the WebSocket connection. Currently, implementing mute requires manually stopping audio sends and managing KeepAlive messages to prevent connection timeout — a pattern that's error-prone and requires understanding Deepgram's connection lifecycle. A simple mute()/unmute() API reduces this to one line of code and handles the KeepAlive internally.

Proposed API

# Sync client
client = deepgram.listen.websocket.v("1")
client.start(options)

# Send audio normally
client.send(audio_data)

# Mute — stops accepting audio, automatically sends KeepAlive
client.mute()
# Audio sent during mute is silently discarded
client.send(audio_data)  # no-op while muted

# Unmute — resumes audio transmission, stops KeepAlive timer
client.unmute()
client.send(audio_data)  # transcribed normally

# Check mute state
if client.is_muted:
    print("Currently muted")

# Async client — same API
await async_client.mute()
await async_client.unmute()

Acceptance criteria

  • mute() method stops forwarding audio to Deepgram and starts automatic KeepAlive
  • unmute() method resumes audio forwarding and stops the KeepAlive timer
  • is_muted property exposes current mute state
  • Audio sent during mute is silently discarded (not queued)
  • Works on both sync and async WebSocket clients
  • Thread-safe for concurrent access
  • Documented with usage example
  • Compatible with existing API

Raised by the DX intelligence system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions