← Back to Workflow
Internal

Audio Alert

Python script that plays an audio alert to get the user's attention when Antigravity needs input.

import sys
import subprocess
import os
import winsound

def speak(text):
    script_dir = os.path.dirname(os.path.abspath(__file__))
    
    # if "Claude" in text:
    #     wav_file = os.path.join(script_dir, "switch_to_claude.wav")
    # elif "Gemini" in text:
    #     wav_file = os.path.join(script_dir, "switch_to_gemini.wav")
    # else:
    wav_file = None

    if wav_file and os.path.exists(wav_file):
        # Play the custom wav file
        winsound.PlaySound(wav_file, winsound.SND_FILENAME)
    else:
        # Fallback to existing TTS
        pronounce_text = text.replace("Claude", "Clawd")
        ps_cmd = f"Add-Type -AssemblyName System.speech; $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer; $synth.Speak('{pronounce_text}')"
        subprocess.run(["powershell", "-Command", ps_cmd])

if __name__ == "__main__":
    if len(sys.argv) > 1:
        speak(sys.argv[1])
    else:
        speak("Audio alert ready.")

This is used in: