Spaces:
Sleeping
Sleeping
Download witnessbox/script.py from build-small-hackathon/WitnessBox: direct link, hf CLI and curl.
- Browser
- Download file 2.93 kB
-
https://huggingface.co/spaces/build-small-hackathon/WitnessBox/resolve/main/witnessbox/script.py
- Command line
-
hf download hf://spaces/build-small-hackathon/WitnessBox/witnessbox/script.py
-
curl -L -o script.py https://huggingface.co/spaces/build-small-hackathon/WitnessBox/resolve/main/witnessbox/script.py
2.93 kB
| """Scripted, pre-generated beats. | |
| These lines are fixed, so their audio is generated *once* (in parallel via | |
| Modal `.map()` at deploy/warm time — see modal_app.py) and cached on a Volume. | |
| That keeps the dramatic moments — especially the witness's **voice crack** — | |
| off the per-turn latency path and lets us pick the best take of the climax. | |
| The break line has several takes precisely because VoxCPM2's expressive style | |
| varies run-to-run; we generate many and keep the one that cracks best (PRD §10). | |
| """ | |
| from __future__ import annotations | |
| from witnessbox.witness import WITNESS_NAME | |
| # Spoken by the court / framing narration (composed neutral voice or on-screen text). | |
| INTRO_NARRATION = ( | |
| "The witness is sworn. Marcus Reid, Chief Financial Officer of Halcyon " | |
| "Dynamics. Twelve million dollars left the company for a vendor named " | |
| "Meridian Atlantic. You have the floor, counselor. Mind how you say it — " | |
| "he listens for doubt." | |
| ) | |
| # The witness's opening line, composed style. | |
| WITNESS_OPENING = ( | |
| "Counselor. I've answered these questions for the auditors, the board, and " | |
| "two regulators. Ask what you like — I have nothing to hide." | |
| ) | |
| # The climax. Generated in many takes; the best (most broken) take is cached and | |
| # played when the third contradiction lands. Style forced to the 'breaking' tag. | |
| BREAK_LINE = ( | |
| "No— that's… that isn't… I signed it. I knew them. I knew the dates. " | |
| "I signed it." | |
| ) | |
| BREAK_LINE_TAKES = 32 # generate this many; keep the best (PRD §10) | |
| # Played after the break, composed court voice, as the win sting. | |
| WIN_EPILOGUE = ( | |
| "The witness is excused. The record will reflect the contradictions: the " | |
| "timeline, the authorization, the relationship. Well examined, counselor." | |
| ) | |
| # Played if the player runs out of credibility with the bench (lose). | |
| LOSE_LINE = ( | |
| "The bench has heard enough speculation, counselor. The witness is excused — " | |
| "and so are you. Mr. Reid keeps his composure, and his story." | |
| ) | |
| def scripted_beats() -> dict[str, dict]: | |
| """All fixed lines + the voice style each should be rendered in. | |
| Returned as a plain dict so modal_app.py can fan it out over `.map()`. | |
| """ | |
| return { | |
| "intro": {"text": INTRO_NARRATION, "style": "calm, formal, courtroom narrator", "takes": 1}, | |
| "opening": {"text": WITNESS_OPENING, "style": "calm, composed, faintly condescending", "takes": 1}, | |
| "break": {"text": BREAK_LINE, "style": "voice unsteady and cracking, composure gone", "takes": BREAK_LINE_TAKES}, | |
| "win": {"text": WIN_EPILOGUE, "style": "calm, formal, courtroom narrator", "takes": 1}, | |
| "lose": {"text": LOSE_LINE, "style": "calm, formal, courtroom narrator", "takes": 1}, | |
| } | |
| __all__ = [ | |
| "INTRO_NARRATION", | |
| "WITNESS_OPENING", | |
| "BREAK_LINE", | |
| "BREAK_LINE_TAKES", | |
| "WIN_EPILOGUE", | |
| "LOSE_LINE", | |
| "scripted_beats", | |
| "WITNESS_NAME", | |
| ] | |