diff --git a/app/ext/offscreen.js b/app/ext/offscreen.js index 5e8057a..7501847 100644 --- a/app/ext/offscreen.js +++ b/app/ext/offscreen.js @@ -37,7 +37,9 @@ async function start(streamId, tabId) { recordingName = "teams_" + new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19); // Tab capture stream: the chromeMediaSource constraint is the only way to get tab audio/video in an extension. const captureConstraint = { mandatory: { chromeMediaSource: "tab", chromeMediaSourceId: streamId } }; - tabStream = await navigator.mediaDevices.getUserMedia({ audio: captureConstraint, video: captureConstraint }); + const videoConstraint = { mandatory: { ...captureConstraint.mandatory, maxFrameRate: 15 } }; // fewer fps = more bits per frame for slides/text + tabStream = await navigator.mediaDevices.getUserMedia({ audio: captureConstraint, video: videoConstraint }); + for (const t of tabStream.getVideoTracks()) t.contentHint = "detail"; // favor sharpness over motion // Mixer: tab audio + optional mic are mixed into one destination track. audioContext = new AudioContext(); const dest = audioContext.createMediaStreamDestination(); @@ -51,8 +53,8 @@ async function start(streamId, tabId) { } catch { micStream = null; } // Output stream: tab video + mixed audio. const outStream = new MediaStream([...tabStream.getVideoTracks(), ...dest.stream.getAudioTracks()]); -// VP8 video + Opus audio at 1 Mbps video, a format the server's ffmpeg pipeline accepts. - recorder = new MediaRecorder(outStream, { mimeType: "video/webm;codecs=vp8,opus", videoBitsPerSecond: 1e6 }); +// VP8 video + Opus audio at 3 Mbps video (1 Mbps gave blocky/ringing text on shared screens). + recorder = new MediaRecorder(outStream, { mimeType: "video/webm;codecs=vp8,opus", videoBitsPerSecond: 3e6 }); // Each 10 s chunk is uploaded in order through the uploadQueue promise chain. recorder.ondataavailable = event => { // Chain the upload on uploadQueue so chunks reach the server in order; count success or failure, then flush events. diff --git a/app/flow.py b/app/flow.py index 4795341..de39960 100644 --- a/app/flow.py +++ b/app/flow.py @@ -185,14 +185,19 @@ def meeting( except (OSError, ValueError): previous_shots = [] no_shots = (db.GLOBAL / "skip_shots.txt").exists() # GUI toggle "Salta schermate" - skip_shots = no_shots - # Toggle on with no prior shots: write empty placeholders so downstream steps find their files. - if no_shots and not previous_shots: + # Dropped video: reuse the shots already extracted; dropped source: reuse audio.opus (no audio/shots re-extraction). + no_video = db.media(name)[1] is None + skip_shots = no_shots or no_video + # Toggle on (or no video) with no prior shots: write empty placeholders so downstream steps find their files. + if skip_shots and not previous_shots: for file_name in ("shots.json", "glossary.json"): (db.out_dir(name) / file_name).write_text("[]") db.replace_shots(name, []) if skip_shots and should_run("shots"): print("shots skipped") + + def audio_ok(): + return (db.out_dir(name) / "audio.opus").exists() # Title/render restart: re-run only text-only post-processing, no vision model needed. if start_from == "title": llama_server.ensure(vision=False) @@ -201,14 +206,14 @@ def meeting( elif start_from == "render": memory.run(name, link=False) else: - if should_run("audio"): + if should_run("audio") and db.media(name)[0]: audio_task(name) # Speaker labelling: diarize, then name mapping. def speaker_chain(): return ( [diarize_task(name, speakers), speakers_task(name)] - if should_run("diarize") + if should_run("diarize") and audio_ok() else ([speakers_task(name)] if should_run("speakers") else None) ) @@ -245,7 +250,7 @@ def meeting( shots_future.result() else: # Sequential path (CUDA, or NPU without shots). - if should_run("transcribe"): + if should_run("transcribe") and audio_ok(): transcribe_task(name, model, device) speaker_chain() if should_run("shots") and not skip_shots: diff --git a/app/report.py b/app/report.py index ef5fcd1..e1bd937 100644 --- a/app/report.py +++ b/app/report.py @@ -66,6 +66,11 @@ def _tick(note): db.tick(PROG[0], PROG[1], max(PROG[2], PROG[1] + 1) if note != "fine" else PROG[1], note) +# User refinement prompt saved in meta (set from the reprocess dialog); appended to topic and overview prompts. +def _refine(name): + text = db.meta(name).get("refine", "") + return f"\nIstruzioni aggiuntive dell'utente per il report: {text}" if text else "" + # Title typed manually in the meeting metadata (wins over the LLM title). def _manual_title(name): return db.meta(name).get("title", "") @@ -492,8 +497,8 @@ def run(name, window_words=3000): n_chunks + 3 * n_chunks + 1, ] # chunks + ~3 topics per chunk (docs pass) + overview db.tick(name, 0, PROG[2], f"argomenti: blocco 1 di {n_chunks}") - # System prompt + glossary (or "nessuno"). - system = SYS_A + (", ".join(glossary) or "nessuno") + # System prompt + glossary (or "nessuno") + optional user refinement. + system = SYS_A + (", ".join(glossary) or "nessuno") + _refine(name) topics, buffer, words, wstart = [], [], 0, 0 # Send the buffered chunk to the LLM and append its topics. @@ -569,7 +574,7 @@ def run(name, window_words=3000): # Overview pass: title and TL;DR from the topics. overview = ( chat( - SYS_B, + SYS_B + _refine(name), json.dumps( [ { diff --git a/app/server.py b/app/server.py index a9fad2e..74c0365 100644 --- a/app/server.py +++ b/app/server.py @@ -217,8 +217,7 @@ def run_all(start_from): for row in db.connect().execute( "SELECT name FROM recordings WHERE status!='recording' ORDER BY name" ): - if db.media(row[0])[0]: - launch(row[0], start_from) # no source video (drop_video): no re-elaboration + launch(row[0], start_from) return True @@ -929,7 +928,7 @@ class Handler(BaseHTTPRequestHandler): # POST: ingestion (/chunk, /events, /upload), recording control, and actions. def do_POST(self): parsed = urlparse(self.path) - params = {key: value[0] for key, value in parse_qs(parsed.query).items()} + params = {key: value[0] for key, value in parse_qs(parsed.query, keep_blank_values=True).items()} name = Path(params.get("name", "x")).name if parsed.path == "/upload": return self.upload(params) @@ -1019,9 +1018,10 @@ class Handler(BaseHTTPRequestHandler): b"not found", 404 ) elif parsed.path == "/run": - if not db.media(name)[0]: - return self._send(b"video eliminato: rielaborazione non possibile", 409) # Re-run the flow from a step (default audio), with optional speaker count. + # `refine` (even empty) replaces the saved report-refinement prompt; absent = keep. + if "refine" in params: + db.set_meta(name, refine=params["refine"].strip()) launched = launch(name, params.get("from", "audio"), int(params.get("speakers") or 0)) self._send( b"" if launched else "già in coda o in esecuzione".encode(), diff --git a/app/ui/index.html b/app/ui/index.html index 6b64f22..45ffe6c 100644 --- a/app/ui/index.html +++ b/app/ui/index.html @@ -47,6 +47,7 @@
Riprocessa riunione
Inizia da:
+
diff --git a/app/ui/ui.js b/app/ui/ui.js index daee899..fdbb955 100644 --- a/app/ui/ui.js +++ b/app/ui/ui.js @@ -35,8 +35,8 @@ async function srch(){if(!q.value){sr.innerHTML="";return}const results=await (a sr.innerHTML=results.speech.map(hit=>`
${E(hit[0])} ${fmt(hit[1])} ${E(hit[2]||"")}: ${E(hit[3])}
`).join("")+results.screen.map(hit=>`
🖥 ${E(hit[0])} ${fmt(hit[1])} ${E(hit[2]||"")}: ${E(hit[3])}
`).join("")+CLOSE("q","sr")} // Reprocess dialog: pick the first step, then start the pipeline from it (/run); 409 means it is already running. let rname=""; -function reprocess(name){rname=name;rstep.innerHTML=["audio","transcribe","diarize","speakers","shots","docs","report","memory","render"].map(step=>`