Skip to content

Conversation

hardiksondagar
Copy link

🎵 Audio Output Controls

Adds comprehensive audio output control methods to the Conversation API, giving developers fine-grained control over audio playback.

✨ New Features

setOutputMuted(boolean)

  • Mute/unmute audio output while preserving playback position
  • Audio continues playing but is silent when muted
  • Immediately affects both current and future audio
  • Perfect for temporary audio silencing

interrupt()

  • Completely stops and clears current audio playback
  • Clears all buffered audio from the pipeline
  • Respects mute state when restoring volume
  • Ideal for stopping long audio responses

🔧 Implementation Details

  • Enhanced VoiceConversation class with robust audio control
  • Added methods to BaseConversation for consistent API
  • Leverages existing WebAudio worklet messaging (interrupt, clearInterrupted)
  • Maintains mute state across audio chunks
  • Updated fadeOutAudio to respect mute state

📚 Usage Examples

// Simple mute/unmute (audio continues)
conversation.setOutputMuted(true);   // Silent
conversation.setOutputMuted(false);  // Audible again

// Stop long audio completely
conversation.interrupt();

// Combined usage
conversation.setOutputMuted(true);  // Mute first
conversation.interrupt();           // Stop and clear
// New audio will be muted when it arrives

📖 Documentation

  • Updated README with comprehensive examples
  • Clear distinction between mute vs interrupt functionality
  • Added to conversation API reference

🎯 Use Cases

  • Mute: Temporary silence during phone calls, notifications
  • Interrupt: Stop long AI responses, user interruptions, navigation changes

Resolves the need for immediate audio control in conversational AI applications.

@jmayalag
Copy link

Shouldn't this be implemented as a pause/play feature? Mute/unmute should never affect the playback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants