CastCircle: An AI Scene Partner for Actors

The Problem

I chaperoned my son and his classmates on a thespian event in SoCal. On the way I was watching him and his friends hassle people to run lines with them. The obvious question: why can’t they just practice on their own? CastCircle is a Flutter app that plays the other characters’ lines using on-device neural TTS (Kokoro MLX, ~340 MB, 15 voices), listens via SFSpeechRecognizer with vocabulary hints, and auto-advances when you nail the line. Entirely offline, no cloud dependencies.

How It Works

Import a Script

CastCircle can ingest scripts in three ways: paste text, import a PDF, or take a photo of a printed page. The script parser is the most complex component — it auto-detects three common script formats:

  1. Standard format — character name in caps followed by dialogue
  2. Name-on-own-line (Gutenberg style) — character name on its own line, dialogue below
  3. Title-case / First Folio (Shakespeare) — historical formatting conventions

The parser handles OCR error correction (from photographed scripts), fuzzy name matching, dehyphenation across line breaks, and abbreviation resolution (HAM becomes HAMLET). It uses Google ML Kit for on-device OCR — no cloud upload needed.

Assign Voices

Each character gets a voice. CastCircle infers character gender from title prefixes (Mr./Mrs.), a built-in name database, and pronoun context in the dialogue. It then maps characters to appropriate Kokoro MLX voices (~340 MB on-device neural text-to-speech engine) with accent selection (American or British English, 15 voices total).

The audio priority chain:

  1. Real cast recordings (if other actors have recorded their lines)
  2. Understudy recordings (backup recordings from the cast)
  3. Kokoro MLX neural TTS (on-device, high quality)
  4. System TTS (fallback if Kokoro isn’t available)

Rehearse

The rehearsal engine is a state machine: ready → playingOther → listeningForMe → paused → sceneComplete. CastCircle plays the other character’s line, then listens to you speak yours using Apple’s SFSpeechRecognizer with vocabulary hints — it feeds character names, stage terminology, and the expected words from your line to the speech recognizer, significantly improving recognition accuracy for theatrical dialogue.

When it hears you deliver your line correctly, it automatically advances to the next beat. You can rehearse a scene hands-free, just like running lines with a real scene partner.

Collaborate

CastCircle supports multi-user recording via Supabase: cast members record their lines individually from their own devices, and recordings sync to the cloud. Real recordings automatically take priority over AI-generated voices in rehearsal. There’s also a web editor for managing productions via browser.

The Tech Stack

  • Flutter (iOS primary, Android supported) with Riverpod 2.x state management
  • Drift (SQLite) for local database with typed queries
  • Kokoro via MLX for on-device neural TTS (~340 MB, 15 voices)
  • Apple SFSpeechRecognizer for real-time speech-to-text with vocabulary hints
  • Google ML Kit for on-device OCR (script photos)
  • Supabase for cloud auth, database, and storage (multi-user sync)
  • Fastlane for automated TestFlight builds

What I Learned

  1. Script parsing is kind of a pain. There is no standard but I’d assumed it would be straightforward. But then you get Shakespeare’s First Folio conventions, OCR artifacts from photographed pages, stage directions that look like dialogue, and character abbreviations that vary throughout a single script. The fuzzy matching and heuristic detection took more iteration than any other component.

  2. On-device TTS has caught up to cloud services. Kokoro MLX produces natural-sounding speech that’s genuinely useful for rehearsal — actors can get a feel for pacing and emotional beats, not just words. At 340 MB, it’s small enough for a phone and fast enough for real-time playback. This was not true even a year ago.

  3. Vocabulary hints dramatically improve speech recognition. Feeding the expected dialogue to the speech recognizer gives it perfect context. For theatrical dialogue (unusual names, archaic language, poetic structure), the accuracy improvement is substantial. And it is absolutely clear that Android speech recognition is DRAMATICALLY better than on iOS.

  • CastCircle — AI scene partner for actors (Flutter)