talk-notes 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ """The talk's transcript, from local speech recognition or the source's own captions."""
2
+
3
+ from pathlib import Path
4
+
5
+ from talk_notes.source import Segment, Source
6
+
7
+ METHODS = ("whisper", "captions")
8
+
9
+
10
+ def transcript_params(method: str, language: str | None, device: str = "auto", whisper_model: str | None = None,
11
+ compute_type: str | None = None) -> dict:
12
+ """What decides the transcript's content: changing any of it redoes the transcript."""
13
+ if method == "captions":
14
+ return {"method": method, "language": language}
15
+ if method != "whisper":
16
+ raise ValueError(f"unknown transcript method {method!r}")
17
+ from talk_notes import transcribe # heavy import, only when needed
18
+
19
+ device, model, compute_type = transcribe.whisper_settings(device, whisper_model, compute_type)
20
+ # The device changes speed, not content, so it is not a parameter.
21
+ return {"method": method, "language": language, "whisper_model": model, "compute_type": compute_type}
22
+
23
+
24
+ def get_transcript(source: Source, params: dict, media_dir: Path, device: str = "auto") -> list[Segment]:
25
+ """The transcript described by `params` (from `transcript_params`)."""
26
+ if params["method"] == "captions":
27
+ return source.captions(params["language"])
28
+ from talk_notes import transcribe
29
+
30
+ audio = source.audio(media_dir)
31
+ return transcribe.whisper_transcript(audio, transcribe.resolve_device(device), params["whisper_model"],
32
+ params["compute_type"], params["language"])
talk_notes/util.py ADDED
@@ -0,0 +1,39 @@
1
+ import re
2
+ import shutil
3
+ import subprocess
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def log(msg: str) -> None:
9
+ print(msg, file=sys.stderr, flush=True)
10
+
11
+
12
+ def ffmpeg_exe() -> str:
13
+ """System ffmpeg if installed, otherwise the static build bundled with imageio-ffmpeg."""
14
+ found = shutil.which("ffmpeg")
15
+ if found:
16
+ return found
17
+ import imageio_ffmpeg
18
+
19
+ return imageio_ffmpeg.get_ffmpeg_exe()
20
+
21
+
22
+ def hms(seconds: float) -> str:
23
+ s = int(seconds)
24
+ return f"{s // 3600:02d}:{s % 3600 // 60:02d}:{s % 60:02d}"
25
+
26
+
27
+ def slugify(text: str, max_len: int = 60) -> str:
28
+ slug = re.sub(r"[^a-z0-9]+", "-", text.lower()).strip("-")
29
+ return slug[:max_len].rstrip("-") or "talk"
30
+
31
+
32
+ def media_duration(path: Path) -> float:
33
+ """Duration of a video or audio file in seconds, read with ffmpeg."""
34
+ out = subprocess.run([ffmpeg_exe(), "-i", str(path)], stderr=subprocess.PIPE, text=True, check=False).stderr
35
+ match = re.search(r"Duration: (\d+):(\d+):([\d.]+)", out)
36
+ if not match:
37
+ raise ValueError(f"cannot read the duration of {path}; is it a video file?")
38
+ h, m, sec = match.groups()
39
+ return int(h) * 3600 + int(m) * 60 + float(sec)
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.5
2
+ Name: talk-notes
3
+ Version: 0.1.0
4
+ Summary: Turn a recorded tech talk into a transcript aligned with its slides, plus an LLM-written reference report
5
+ Project-URL: Homepage, https://github.com/ManuelCarullo/talk-notes
6
+ Project-URL: Issues, https://github.com/ManuelCarullo/talk-notes/issues
7
+ Author: Manuel Carullo
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: knowledge-base,llm,slides,talks,transcript,whisper
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Multimedia :: Video
21
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: av<16
24
+ Requires-Dist: faster-whisper>=1.1
25
+ Requires-Dist: imagehash>=4.3
26
+ Requires-Dist: imageio-ffmpeg>=0.5
27
+ Requires-Dist: pillow>=10
28
+ Requires-Dist: yt-dlp[default]>=2025.11
29
+ Provides-Extra: gpu
30
+ Requires-Dist: nvidia-cublas-cu12; extra == 'gpu'
31
+ Requires-Dist: nvidia-cudnn-cu12<10,>=9; extra == 'gpu'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # talk-notes
35
+
36
+ Turns a recorded tech talk into a knowledge-base entry:
37
+
38
+ - `slides/`: one image per slide, detected from the video.
39
+ - `talk.md`: the transcript grouped under each slide, with timestamp links back to the video.
40
+ - `report.md` (optional): a structured reference document written by an LLM from `talk.md` and the slides.
41
+
42
+ Download, transcription and slide detection run locally (yt-dlp, faster-whisper, ffmpeg). The slide crop and the report use an LLM: the Claude Code CLI (default) or a local Ollama model, so the whole pipeline can run offline.
43
+
44
+ ## Install
45
+
46
+ ```sh
47
+ uv tool install talk-notes # CPU only
48
+ uv tool install "talk-notes[gpu]" # NVIDIA GPU (CUDA 12)
49
+ ```
50
+
51
+ Or run it without installing: `uvx talk-notes ...`. `pip install talk-notes` works too. YouTube downloads also need Node or Deno on `PATH`. ffmpeg is taken from `PATH`, or a bundled build is used.
52
+
53
+ ## Usage
54
+
55
+ ```sh
56
+ talk-notes "https://www.youtube.com/watch?v=VIDEO_ID" # report via Claude Code
57
+ talk-notes ~/Videos/talk.mp4 --device cuda --llm ollama # fully local
58
+ talk-notes "https://www.youtube.com/watch?v=VIDEO_ID" --no-report --crop none # no LLM
59
+ ```
60
+
61
+ The source is a local video or any URL yt-dlp supports. Output goes to `out/<title>-<id>/` in the current directory. Run `talk-notes --help` for all options.
62
+
63
+ Reruns reuse each step (transcript, crop, slides, report) until an option that affects it changes; changing `--slide-threshold`, for example, redoes the slides and the report but not the transcript. `--redo slides,report` or `--redo all` forces steps to run again.
64
+
65
+ ### Transcription
66
+
67
+ | Option | Default | Notes |
68
+ |---|---|---|
69
+ | `--device auto\|cpu\|cuda` | `auto` | `auto` uses CUDA when a GPU is visible |
70
+ | `--whisper-model` | `large-v3-turbo` on CUDA, `small` on CPU | Any faster-whisper model |
71
+ | `--language` | auto-detect | Setting it (e.g. `en`) avoids misdetection |
72
+ | `--transcript captions` | `whisper` | Uses the site's captions (URLs only): much faster, but auto-captions lack punctuation |
73
+
74
+ An 18-minute talk takes about 4.5 minutes end to end with `small` on a 4-core CPU. For accents, poor audio or non-English talks, use `--whisper-model large-v3-turbo` on CPU too.
75
+
76
+ ### Slides
77
+
78
+ A frame is sampled every `--slide-interval` seconds and perceptually hashed; a new slide starts where the picture changes by more than `--slide-threshold` bits. Each slide is saved as its last frame, so incremental builds appear complete.
79
+
80
+ - Too many near-duplicates: raise `--min-slide-duration` (8–12 for live coding) or `--slide-threshold`.
81
+ - Missed slides: lower `--slide-threshold`.
82
+ - Add `--keep-media` while tuning, so the video isn't downloaded again.
83
+
84
+ `--crop auto` (default) asks the LLM for the slide area, so a speaker camera or conference banner doesn't trigger new slides. A camera overlaid on full-frame slides is masked during detection but kept in the images. Check `crop/preview.jpg` (crop in red, mask in blue). If it is wrong, pass the box by hand as `--crop w:h:x:y` (ffmpeg syntax, source pixels) or use `--crop none`. If the LLM call fails, the full frame is used.
85
+
86
+ ### Report
87
+
88
+ `report.md` classifies the talk (problem-solving story, argument, tutorial, catalogue, product demo or mixed) and follows that type's outline. Each point is labelled **Problem**, **Cause**, **Evidence**, **Solution**, **Recommendation**, **Opinion** or **Caveat**, and anything the model added is marked *(inferred)*. It ends with the slides' code verbatim, **For coding agents** rules (When / Do / Why) and references.
89
+
90
+ `--prompt my-prompt.md` replaces the default instructions ([`talk_notes/prompts/report.md`](https://github.com/ManuelCarullo/talk-notes/blob/main/talk_notes/prompts/report.md)); `{{ISSUES_URL}}` in it expands to this repo's issues page. `--no-report` skips the report.
91
+
92
+ ### LLM backends
93
+
94
+ `--llm` picks the backend for `--crop auto` and the report; `--llm-model` overrides its model.
95
+
96
+ - `claude` (default): runs the Claude Code CLI (`claude -p`) read-only in the output folder.
97
+ - `ollama`: uses a local Ollama server (`--ollama-url`, default `http://localhost:11434`; model `qwen3-vl:8b-instruct`). Start it with `OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve` to fit more of the model on the GPU.
98
+
99
+ > [!WARNING]
100
+ > Small local models can get the crop wrong and put made-up claims, quotes and links in the report. Use `ollama` only with a GPU that can run models larger than 8 GB, and check its reports against `talk.md`.
101
+
102
+ ## Using the output
103
+
104
+ Copy the talk folder (or `report.md` and `slides/`) into a repo's docs and reference it from `CLAUDE.md` or `AGENTS.md`, e.g. `See docs/talks/<name>/report.md for ...`. For exact quotes, `talk.md` is the source of truth.
105
+
106
+ ## Development
107
+
108
+ ```sh
109
+ git clone https://github.com/ManuelCarullo/talk-notes && cd talk-notes
110
+ uv sync # add --extra gpu for CUDA
111
+ uv run talk-notes ...
112
+ uv run pytest && uv run ruff check talk_notes tests
113
+ ```
114
+
115
+ ## License
116
+
117
+ MIT, see [LICENSE](https://github.com/ManuelCarullo/talk-notes/blob/main/LICENSE). The license covers talk-notes, not its output: transcripts, slides and reports derive from the talks and remain subject to their copyright and the hosting site's terms. Process only talks you have the right to use, and publish the output only if you are allowed to.
@@ -0,0 +1,23 @@
1
+ talk_notes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ talk_notes/__main__.py,sha256=9HRyZLetvQvI9Ci01TNzRCDchGD4uYFc2v3kz9xZZCY,40
3
+ talk_notes/cli.py,sha256=2VFBArdhEdQfXvSnKIEy9A7hg_dl4u5towGfD5S0gj8,7683
4
+ talk_notes/crop.py,sha256=7kHHCNnIBcnneZUCNVzZf01PZ8JwMqmgWFgElMh4wfQ,9083
5
+ talk_notes/render.py,sha256=h15U5RDjGphl2vRzAh45QRUBXRixd-JfhTVb8LGxgFY,1936
6
+ talk_notes/report.py,sha256=JiRlSTM2Co-jF-hS6Y_MgTHLEbBqdaWm0I9R15efNIc,1490
7
+ talk_notes/slides.py,sha256=MImsocfBO4Nj068RkN7jNwKptgchEiQpJnYzhe0A47M,5230
8
+ talk_notes/source.py,sha256=B9Y-aht-dvhHwBjLqcW-rqkDMxjVP4hpaYPFg71ohWY,6470
9
+ talk_notes/talk_folder.py,sha256=epB5hs2sh3cL0gCX3zTeuVCUKAD2UO5jWkT1i_dNMZs,6213
10
+ talk_notes/transcribe.py,sha256=mEhH7k31IwJviGzDC47fRiPYKeUSjXQkheKiCsvyD1U,2380
11
+ talk_notes/transcript.py,sha256=HAr-T9dMN-7H_HzO3lyINz6XVdanO71w9Ut1lgR1v1g,1536
12
+ talk_notes/util.py,sha256=oL9uCGkxInOg2_mi8T7CYgnghieNR9F_yib7SIUhJTI,1172
13
+ talk_notes/llm/__init__.py,sha256=4yIqihrh7y4UbLJ9pYXyWRyS2o_HEuFsO9DoLUKtMxo,1694
14
+ talk_notes/llm/base.py,sha256=z2bk58dJZwuq0ptdsqZaL54CtRC5Bpw65zkP9KbS_Ss,615
15
+ talk_notes/llm/claude_code.py,sha256=tzRsqZLhj0BZdpbOvvfg_lsMgDGYOfIA_mLtj3bbJts,1859
16
+ talk_notes/llm/fake.py,sha256=0eWd_GIEzfXeVLzsFUqluMs7YHmQNqkxCr5jvKGxBIk,924
17
+ talk_notes/llm/ollama.py,sha256=broXGv0ipr8gaY3foA6ZWxFB3vb0ZyRjhhj9-qj9VaE,5889
18
+ talk_notes/prompts/report.md,sha256=4I3X3lG3vR83j1HBdc3_VVgJ3ezJHFJZVqvnXYEsGIo,4812
19
+ talk_notes-0.1.0.dist-info/METADATA,sha256=Q0u11r2mIklM7FW5w2jFv19958-hO11zTkLtxGIUa7w,6683
20
+ talk_notes-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
21
+ talk_notes-0.1.0.dist-info/entry_points.txt,sha256=BZwZCS46VLnbWvRG0vA-pAtufWp7zSZZdAr2aUVllMI,51
22
+ talk_notes-0.1.0.dist-info/licenses/LICENSE,sha256=JFrwuEQJtZzs3HayzNqxfO5f9KSPSqMEjLZpeV5ZaaY,1071
23
+ talk_notes-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ talk-notes = talk_notes.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manuel Carullo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.