Idriz v0.1: Realtime voice assistant with Wikipedia summaries and coloring pages
- OpenAI Realtime session (server VAD, half-duplex audio via pacat/PipeWire) - Tools: wikipedia_sazetak (en.wikipedia -> Bosnian summary, max 2 A4 pages via WeasyPrint) and bojanka (image generation -> pure line art on A4) - CUPS printing, systemd user service, install script, offline test script Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzKpYaEsuWDevuNnvSjcFW
This commit is contained in:
30
scripts/test_summary.py
Normal file
30
scripts/test_summary.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Ručni test: Wikipedia -> (opciono) sažetak -> PDF. Bez ključa radi samo sa sirovim tekstom članka."""
|
||||
import asyncio
|
||||
import html
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from idriz import render, textgen, wiki # noqa: E402
|
||||
from idriz.config import load # noqa: E402
|
||||
|
||||
|
||||
async def main(topic: str, age: str) -> None:
|
||||
cfg = load()
|
||||
art = wiki.find_article(topic)
|
||||
if not art:
|
||||
print("nema članka"); return
|
||||
print("članak:", art.title, art.url, len(art.text), "znakova")
|
||||
out = Path("out"); out.mkdir(exist_ok=True)
|
||||
if cfg.openai_api_key:
|
||||
from openai import AsyncOpenAI
|
||||
title, body = await textgen.summarize(AsyncOpenAI(api_key=cfg.openai_api_key), cfg.text_model, art, topic, age)
|
||||
else:
|
||||
title = art.title
|
||||
body = "".join(f"<p>{html.escape(p)}</p>" for p in art.text.split("\n\n")[:12])
|
||||
pdf = render.render_summary(title, body, art.title, out / "test-sazetak.pdf", cfg.max_pages)
|
||||
print("PDF:", pdf)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main(sys.argv[1] if len(sys.argv) > 1 else "Volcano", sys.argv[2] if len(sys.argv) > 2 else "10"))
|
||||
Reference in New Issue
Block a user