earshot-cli 0.8.0__tar.gz → 0.9.0__tar.gz
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.
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/PKG-INFO +8 -6
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/README.md +6 -4
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/pyproject.toml +2 -2
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/__init__.py +3 -3
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/cli.py +14 -5
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_wizard.py +26 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/uv.lock +1 -1
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/.github/workflows/ci.yml +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/.github/workflows/publish.yml +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/.gitignore +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/LICENSE +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/scripts/download_models.sh +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/auth.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/capture.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/compose.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/config.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/deliver.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/extract.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/hardsub.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/live.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/models.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/subtitle.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/transcribe.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/src/earshot/transcribe_cloud.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/conftest.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_auth.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_compose.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_config.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_credential_lifecycle.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_deliver.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_deliver_api.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_do_deliver.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_extract.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_hardsub.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_live.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_me.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_subtitle.py +0 -0
- {earshot_cli-0.8.0 → earshot_cli-0.9.0}/tests/test_ua.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: earshot-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: 媒体剪藏:视频字幕/系统声听录/本地音频/硬字幕OCR 四路摄入,端侧转写 → Markdown → 投递知识库(默认 ExoMind,可插拔)
|
|
5
5
|
Project-URL: Homepage, https://github.com/helloworldtang/earshot
|
|
6
6
|
Project-URL: Repository, https://github.com/helloworldtang/earshot
|
|
7
7
|
Project-URL: Issues, https://github.com/helloworldtang/earshot/issues
|
|
@@ -35,13 +35,15 @@ Description-Content-Type: text/markdown
|
|
|
35
35
|
|
|
36
36
|
# earshot
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
媒体剪藏:**听到看到的,都能进知识库。**
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
给它一条视频链接,或听播客/讲座时开着它,内容自动转写为 Markdown 并投递到你的知识库(默认 [ExoMind 知识飞轮](https://exomind.ai-as.cn),可插拔任意 webhook)。纯端侧转写,无限流、零 API 费用。
|
|
41
41
|
|
|
42
42
|
```
|
|
43
|
-
系统声音 ──录制──> 16k wav ──silero VAD 切段──> SenseVoice 端侧识别(实时字幕)
|
|
44
|
-
视频链接 ──yt-dlp──> 平台字幕(ai-zh/CC)
|
|
43
|
+
系统声音 ──录制──> 16k wav ──silero VAD 切段──> SenseVoice 端侧识别(实时字幕) ─┐
|
|
44
|
+
视频链接 ──yt-dlp──> 平台字幕(ai-zh/CC,高信噪比路线) ─────────────────────────┼──> Markdown ──> 投递(exomind / webhook / 仅存档)
|
|
45
|
+
本地音频 ──文件──> 16k wav ──VAD 切段──> SenseVoice 端侧识别 ──────────────────┤
|
|
46
|
+
硬字幕视频 ──ffmpeg 抽帧──> PaddleOCR(无音轨路线) ─────────────────────────────┘
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
## 安装(开箱即用)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# earshot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
媒体剪藏:**听到看到的,都能进知识库。**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
给它一条视频链接,或听播客/讲座时开着它,内容自动转写为 Markdown 并投递到你的知识库(默认 [ExoMind 知识飞轮](https://exomind.ai-as.cn),可插拔任意 webhook)。纯端侧转写,无限流、零 API 费用。
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
系统声音 ──录制──> 16k wav ──silero VAD 切段──> SenseVoice 端侧识别(实时字幕)
|
|
9
|
-
视频链接 ──yt-dlp──> 平台字幕(ai-zh/CC)
|
|
8
|
+
系统声音 ──录制──> 16k wav ──silero VAD 切段──> SenseVoice 端侧识别(实时字幕) ─┐
|
|
9
|
+
视频链接 ──yt-dlp──> 平台字幕(ai-zh/CC,高信噪比路线) ─────────────────────────┼──> Markdown ──> 投递(exomind / webhook / 仅存档)
|
|
10
|
+
本地音频 ──文件──> 16k wav ──VAD 切段──> SenseVoice 端侧识别 ──────────────────┤
|
|
11
|
+
硬字幕视频 ──ffmpeg 抽帧──> PaddleOCR(无音轨路线) ─────────────────────────────┘
|
|
10
12
|
```
|
|
11
13
|
|
|
12
14
|
## 安装(开箱即用)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "earshot-cli"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.9.0"
|
|
4
|
+
description = "媒体剪藏:视频字幕/系统声听录/本地音频/硬字幕OCR 四路摄入,端侧转写 → Markdown → 投递知识库(默认 ExoMind,可插拔)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
authors = [{ name = "Jackie" }]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"""earshot
|
|
1
|
+
"""earshot:媒体剪藏 —— 听到看到的都能进知识库。
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
→ 组装 Markdown → 投递(默认 exomind CLI,可插拔 webhook)。
|
|
3
|
+
跨平台桌面端四路摄入:视频字幕(平台已生成文本)/系统声听录(macOS 需 BlackHole)
|
|
4
|
+
/本地音频/硬字幕OCR → 端侧转写 → 组装 Markdown → 投递(默认 exomind CLI,可插拔 webhook)。
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from importlib import metadata as _metadata
|
|
@@ -40,10 +40,13 @@ EXIT_NO_CONTENT = 2
|
|
|
40
40
|
|
|
41
41
|
_LEVEL_BLOCKS = "▁▂▃▄▅▆▇█"
|
|
42
42
|
|
|
43
|
+
# 各摄入路线的默认 tag(与来源语义对齐,不再是清一色「旁听」);手动补投无来源,用通用词
|
|
44
|
+
DEFAULT_TAG_BY_SOURCE = {"listen": "旁听", "video": "视频字幕", "audio": "本地转写", "ocr": "硬字幕"}
|
|
45
|
+
|
|
43
46
|
|
|
44
47
|
def _add_common(p: argparse.ArgumentParser) -> None:
|
|
45
48
|
p.add_argument("--title", help="笔记标题(默认取首句截断)")
|
|
46
|
-
p.add_argument("--tag", action="append", default=None, help="投递标签,可多次(
|
|
49
|
+
p.add_argument("--tag", action="append", default=None, help="投递标签,可多次(默认按来源定)")
|
|
47
50
|
p.add_argument("--note", default="", help="来源备注,如「B站·xxx第3期」,写进脚注")
|
|
48
51
|
p.add_argument("--engine", choices=["local", "server"], default="local", help="转写引擎(默认 local 端侧)")
|
|
49
52
|
p.add_argument(
|
|
@@ -58,7 +61,7 @@ def _add_common(p: argparse.ArgumentParser) -> None:
|
|
|
58
61
|
|
|
59
62
|
|
|
60
63
|
def build_parser() -> argparse.ArgumentParser:
|
|
61
|
-
parser = argparse.ArgumentParser(prog="earshot", description="
|
|
64
|
+
parser = argparse.ArgumentParser(prog="earshot", description="媒体剪藏:听到看到的都能进知识库")
|
|
62
65
|
parser.add_argument("--version", action="version", version=f"earshot {__version__}")
|
|
63
66
|
sub = parser.add_subparsers(dest="command") # 不带子命令时进入交互向导
|
|
64
67
|
|
|
@@ -154,7 +157,7 @@ def _run_pipeline(
|
|
|
154
157
|
|
|
155
158
|
segments = add_punctuation(segments) # 无标点转写(B站AI字幕)按时间轴补齐;已有标点自动跳过
|
|
156
159
|
title = derive_title(segments, args.title)
|
|
157
|
-
tags = args.tag if args.tag else ["
|
|
160
|
+
tags = args.tag if args.tag else [DEFAULT_TAG_BY_SOURCE.get(meta.source, "剪藏")]
|
|
158
161
|
paragraphs = ["".join(s.text for s in group) for group in group_paragraphs(segments, chapter_breaks=chapter_breaks)]
|
|
159
162
|
md = render_markdown(meta, paragraphs, title)
|
|
160
163
|
|
|
@@ -444,6 +447,11 @@ def cmd_video(args: argparse.Namespace, settings: Settings) -> int:
|
|
|
444
447
|
print(f"✗ {e}")
|
|
445
448
|
return EXIT_FAIL
|
|
446
449
|
print(f"→ {meta.title}(UP:{meta.uploader},字幕:{meta.subtitle_lang},{len(segments)} 段)")
|
|
450
|
+
if not segments:
|
|
451
|
+
# 字幕轨 0 条是正确事实(硬字幕烧在画面里),别让用户在这里空手而归——接住最常见的走错路
|
|
452
|
+
print("✗ 该视频无外挂字幕轨(疑似硬字幕烧录)")
|
|
453
|
+
print(f" → 可改走画面识别:earshot ocr {url}")
|
|
454
|
+
return EXIT_NO_CONTENT
|
|
447
455
|
if not args.title:
|
|
448
456
|
args.title = meta.title # 视频有正标题,优先于首句截断
|
|
449
457
|
if not args.note:
|
|
@@ -553,7 +561,7 @@ def cmd_deliver(args: argparse.Namespace, settings: Settings) -> int:
|
|
|
553
561
|
if not title:
|
|
554
562
|
first = next((ln[2:].strip() for ln in md.splitlines() if ln.startswith("# ")), "")
|
|
555
563
|
title = first or md_path.stem
|
|
556
|
-
tags = args.tag if args.tag else ["
|
|
564
|
+
tags = args.tag if args.tag else ["剪藏"] # 手动补投无来源信息,用通用 tag
|
|
557
565
|
if args.deliver == "none":
|
|
558
566
|
print("跳过投递(--deliver none)")
|
|
559
567
|
return EXIT_OK
|
|
@@ -742,7 +750,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
742
750
|
if not _interactive():
|
|
743
751
|
parser.print_help()
|
|
744
752
|
return EXIT_FAIL
|
|
745
|
-
|
|
753
|
+
menu = "earshot 模式 [1]视频字幕 [2]听录 [3]本地音视频转写 [4]硬字幕OCR(回车=1;输入 q 退出)"
|
|
754
|
+
choice = _prompt(menu, default="1")
|
|
746
755
|
if choice == "q":
|
|
747
756
|
return EXIT_OK
|
|
748
757
|
mapping = {"1": "video", "2": "listen", "3": "audio", "4": "ocr"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"""交互向导单测:非 tty 的回退行为与裸 earshot 入口。"""
|
|
2
2
|
|
|
3
|
+
from datetime import datetime
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
|
|
5
6
|
import pytest
|
|
6
7
|
|
|
7
8
|
from earshot import cli
|
|
8
9
|
from earshot.config import Settings
|
|
10
|
+
from earshot.transcribe import Segment
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
def _settings() -> Settings:
|
|
@@ -79,3 +81,27 @@ def test_short_url_strips_tracking_and_truncates() -> None:
|
|
|
79
81
|
assert cli._short_url(long_q) == "https://www.bilibili.com/video/BV16qpF64E6V/"
|
|
80
82
|
assert cli._short_url("https://" + "a" * 100).endswith("…")
|
|
81
83
|
assert len(cli._short_url("https://" + "a" * 100)) == 61
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_video_no_subtitle_tracks_hints_ocr(monkeypatch: pytest.MonkeyPatch, capsys) -> None: # type: ignore[no-untyped-def]
|
|
87
|
+
"""字幕轨 0 条(硬字幕)时不能空手而归:给出可执行的 ocr 改走指引。"""
|
|
88
|
+
from earshot.subtitle import VideoMeta
|
|
89
|
+
|
|
90
|
+
meta = VideoMeta(title="硬字幕视频", uploader="u", duration_s=1.0, url="https://b23.tv/x", subtitle_lang="")
|
|
91
|
+
monkeypatch.setattr(cli, "fetch_video_note", lambda _url, _cookies: (meta, []))
|
|
92
|
+
args = cli.build_parser().parse_args(["video", "https://b23.tv/x", "-y"])
|
|
93
|
+
rc = cli.cmd_video(args, _settings())
|
|
94
|
+
out = capsys.readouterr().out
|
|
95
|
+
assert rc == cli.EXIT_NO_CONTENT
|
|
96
|
+
assert "earshot ocr https://b23.tv/x" in out
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_run_pipeline_default_tag_follows_source(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
|
100
|
+
"""默认 tag 按摄入路线走(video→视频字幕),不再清一色「旁听」。"""
|
|
101
|
+
captured: dict[str, object] = {}
|
|
102
|
+
monkeypatch.setattr(cli, "_do_deliver", lambda *a: captured.update(tags=a[3]) or 0)
|
|
103
|
+
args = cli.build_parser().parse_args(["video", "https://x", "-y", "--out", str(tmp_path)])
|
|
104
|
+
meta = cli.NoteMeta(started_at=datetime.now(), duration_s=1.0, device="-", source="video", note="")
|
|
105
|
+
rc = cli._run_pipeline([Segment(0.0, 1.0, "内容")], meta, args, _settings())
|
|
106
|
+
assert rc == 0
|
|
107
|
+
assert captured["tags"] == ["视频字幕"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|