Skip to content

Commit

Permalink
Add a manual entry mode for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ehennenfent committed May 4, 2024
1 parent 7329835 commit 360fbb6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions live_illustrate/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def get_args() -> argparse.Namespace:
type=float,
help="How much of the previous transcription to retain after generating each summary. 0 - 1.0",
)
parser.add_argument(
"--oneshot",
type=argparse.FileType("r"),
help="Read transcription lines from a text file and render. Useful for testing.",
)
parser.add_argument("-v", "--verbose", action="count", default=0)
return parser.parse_args()

Expand All @@ -93,8 +98,11 @@ def main() -> None:
logging.getLogger("requests").setLevel(logging.INFO if args.verbose > 0 else logging.WARNING)
logging.getLogger("werkzeug").setLevel(logging.INFO if args.verbose > 0 else logging.WARNING) # flask

# create each of our thread objects with the apppropriate command line args
transcriber = AudioTranscriber(model=args.audio_model, phrase_timeout=args.wait_minutes * args.phrase_timeout)
# We don't test transcription in oneshot mode
if not (is_oneshot := args.oneshot is not None):
transcriber = AudioTranscriber(model=args.audio_model, phrase_timeout=args.wait_minutes * args.phrase_timeout)

# Create each of our thread objects with the apppropriate command line args
buffer = TextBuffer(
wait_minutes=args.wait_minutes, max_context=args.max_context, persistence=args.persistence_of_memory
)
Expand Down Expand Up @@ -127,7 +135,8 @@ def on_image_rendered(image: Image | None) -> None:
session_data.save_image(image)

# start each thread with the appropriate callback
Thread(target=transcriber.start, args=(on_text_transcribed,), daemon=True).start()
if not is_oneshot:
Thread(target=transcriber.start, args=(on_text_transcribed,), daemon=True).start()
Thread(target=summarizer.start, args=(on_summary_generated,), daemon=True).start()
Thread(target=renderer.start, args=(on_image_rendered,), daemon=True).start()

Expand All @@ -145,6 +154,12 @@ def open_browser() -> None:

Thread(target=lambda: open_browser).start()

if is_oneshot:
# Read all the lines from the file, pretend we transcribed them
for line in args.oneshot: # type: ignore
# This will still dump things in the data directory. No sense short circuiting the testing.
on_text_transcribed(Transcription(line.strip()))

# flask feels like it probably has a good ctrl+c handler, so we'll make this one the main thread
server.start()

Expand Down

0 comments on commit 360fbb6

Please sign in to comment.