This project is a voice-controlled web automation agent built on top of Stagehand (Playwright-based). It can:
- Run a demo that automates a browser session and showcases Stagehand’s
extract/act/observeand agent capabilities - Run an interactive voice loop that listens to your microphone, transcribes speech, interprets intent via LLMs, and executes actions in the browser
npm install
npm start # Demo run (Browserbase session)
# or
npm run voice # Interactive voice control (local browser)- Node.js 18+ and npm
- macOS/Linux/WSL. For voice mode on macOS, ensure microphone permissions are granted to your terminal.
- For voice capture, SoX is required by
node-record-lpcm16:- macOS:
brew install sox - Linux:
sudo apt-get install sox(or your distro’s package manager)
- macOS:
npm installCreate a .env file in stob/ and add API keys:
touch .env
open -a TextEdit .env # or use your editorRequired keys (use at least one per category where applicable):
- OPENAI_API_KEY — used for Whisper fallback (speech-to-text)
- CARTESIA_API_KEY — used for primary speech-to-text via Cartesia (ink-whisper)
- GOOGLE_API_KEY — used for Gemini 2.5 Flash (LLM fallback via OpenAI-compatible endpoint)
- CEREBRAS_API_KEY — used for fast LLM command interpretation
Example .env snippet:
OPENAI_API_KEY=sk-...
CARTESIA_API_KEY=ct-...
GOOGLE_API_KEY=ya29-...
CEREBRAS_API_KEY=cb-...Notes:
- Voice mode prefers Cartesia for STT and falls back to OpenAI Whisper.
- Command interpretation prefers Cerebras and falls back to Gemini 2.5 Flash.
npm start→ Runsindex.ts(Browserbase session) to demo Stagehand basicsnpm run voice→ Runsenhanced-voice-main.tsfor local, voice-controlled automationnpm run build→ TypeScript build (outputs todist/)
npm startWhat happens:
- Creates a Browserbase-backed Stagehand session
- Navigates to
https://stagehand.dev - Demonstrates
page.extract,page.act,page.observe, and anagent.execute - Prints a watch URL to view the live session
npm run voiceWhat happens:
- Launches Stagehand locally with a visible browser and a persistent user profile (
./browser-sessions) - Listens through your mic for a few seconds, transcribes speech, interprets it, and executes actions
- Say “stop”, “exit”, or “quit” to end the loop
Example commands you can speak:
- “Go to YouTube”
- “Search for funny cat videos”
- “Click the first result”
- “What can I click on this page?”
- “Login to Instagram” / “Logout”
- Demo (
index.ts) runs withenv: "BROWSERBASE"and prints a Browserbase session URL. - Voice mode (
enhanced-voice-automation.ts) runs withenv: "LOCAL",headless: false,debugDom: true,persistentContext: true, anduserDataDir: ./browser-sessionsso logins persist across sessions.
index.ts— Minimal Stagehand demo on Browserbaseenhanced-voice-main.ts— Entry point for voice modeenhanced-voice-automation.ts— Voice capture, STT, LLM interpretation, and action executioncerebras-config.ts— Cerebras client and structured command interpretationtsconfig.json— TypeScript configurationpackage.json— Scripts and dependencies
- Grant your terminal microphone access in System Settings → Privacy & Security → Microphone
- Install SoX:
brew install sox - If audio capture fails, quit and restart the terminal after granting permissions
- Missing mic input or immediate “Listening...” then “Error”:
- Ensure SoX is installed and mic permissions are granted
- Try another terminal app if permissions don’t stick
- STT fails (speech-to-text):
- Verify
CARTESIA_API_KEY; if missing, ensureOPENAI_API_KEYis set for Whisper fallback
- Verify
- LLM interpretation fails:
- Verify
CEREBRAS_API_KEY; if missing or failing, ensureGOOGLE_API_KEYis set for Gemini fallback
- Verify
- Browser doesn’t open during voice mode:
- Voice mode runs locally with a visible browser; check for OS-level blocks or Playwright errors in logs
- Slow actions or flakiness:
- Voice mode uses
debugDomand a longdomSettleTimeoutMsfor reliability; network-dependent pages may still vary
- Voice mode uses
- API keys are sensitive. Keep
.envout of source control. - The local profile in
./browser-sessionsmay contain login state. Treat it as sensitive.
See repository license if provided. Otherwise, all rights reserved.