Usage Examples

Basic Speaking

Use say() to speak a simple message aloud:

from blurt import say
say("Hello, world!")

Beep (Cross-platform)

Play a short system beep sound:

from blurt import beep
beep()

Play Sound File

Play a custom .mp3 or .wav file, or the default alert sound:

from blurt import play_sound
play_sound()  # Default alert sound
play_sound("/path/to/your/alert.mp3")

List Available Voices

from blurt import list_voices
voices = list_voices()
print(voices)

Notify When Done (Decorator)

Use @notify_when_done to automatically speak after a function completes:

from blurt import notify_when_done

@notify_when_done("Processing done!")
def process_data():
    print("Working...")
process_data()

Announce During (Context Manager)

Use the announce_during() context manager to announce when a block of code starts and finishes:

from blurt import announce_during

with announce_during("Starting task", "Finished task"):
    for _ in range(3):
        print("Processing...")

Class-based API

from blurt import Blurt
b = Blurt({"rate": 250, "volume": 0.7})
b.say("Custom rate and volume!")
b.beep()
b.play_sound()
voices = b.list_voices()
b.set_rate(300)
b.set_volume(0.5)
b.set_voice("Alex")

Mute All Sounds

You can globally mute all speaking or beeping using an environment variable:

export BLURT_MUTE=true

See Configuration for more options.

Next

See API Reference for detailed reference of each function.