Skip to main content

AudioManager API Reference

The AudioManager class provides comprehensive audio functionality for MentraOS Apps, including URL-based audio playback, text-to-speech synthesis, and audio control. It automatically handles request tracking, timeouts, and provides real-time status monitoring.

Import

Class: AudioManager

The AudioManager is automatically instantiated by the AppSession. You should not create instances directly.

Audio Playback Methods

playAudio

Play audio from a URL on the connected glasses (or the phone).
Parameters:
  • options: Audio playback configuration
Returns: Promise that resolves with playback result Example:

speak

Convert text to speech and play it on the connected glasses.
Parameters:
  • text: Text to convert to speech (required)
  • options: Text-to-speech configuration (optional)
Returns: Promise that resolves with playback result Example:

stopAudio

Stop all audio playback on the connected glasses.
Example:

Request Management Methods

hasPendingRequest

Check if there are pending audio requests.
Parameters:
  • requestId: Optional specific request ID to check
Returns: True if there are pending requests (or specific request exists) Example:

Interfaces

AudioPlayOptions

Options for audio playback from URLs.

SpeakOptions

Options for text-to-speech synthesis.

AudioPlayResult

Result of an audio playback attempt.

Available ElevenLabs TTS Models

Model Selection Guidelines:
  • Use eleven_flash_v2_5 for real-time applications requiring ultra-low latency
  • Use eleven_turbo_v2_5 for a good balance of quality and speed
  • Use eleven_multilingual_v2 for the highest quality emotional expression
  • Use eleven_v3 for maximum language support

Best Practices

1. Check Device Capabilities

2. Handle Errors Gracefully

3. Chain Multiple Audio Requests

4. Allow the User to Interrupt the Audio