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:
16
scripts/install.sh
Executable file
16
scripts/install.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Postavlja venv, systemd korisnički servis i konfiguracioni fajl. Pokretati kao korisnik idriz.
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
[ -d .venv ] || python3 -m venv .venv
|
||||
.venv/bin/pip install -q -r requirements.txt
|
||||
mkdir -p ~/.config/idriz ~/.config/systemd/user
|
||||
if [ ! -f ~/.config/idriz/env ]; then
|
||||
printf 'OPENAI_API_KEY=\n' > ~/.config/idriz/env
|
||||
chmod 600 ~/.config/idriz/env
|
||||
echo "Upiši OPENAI_API_KEY u ~/.config/idriz/env"
|
||||
fi
|
||||
cp systemd/idriz.service ~/.config/systemd/user/idriz.service
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable idriz.service
|
||||
echo "Gotovo. Pokreni sa: systemctl --user start idriz"
|
||||
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