dsh-ai-subtitle 0.0.0-stage → 0.3.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Xijian Yan
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.
package/README.en.md ADDED
@@ -0,0 +1,168 @@
1
+ # dsh-ai-subtitle
2
+
3
+ **English** · [简体中文](README.md) · [日本語](README.ja.md) · [한국어](README.ko.md)
4
+
5
+ [![hygiene](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml/badge.svg)](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![npm](https://img.shields.io/npm/v/dsh-ai-subtitle.svg)](https://www.npmjs.com/package/dsh-ai-subtitle)
8
+ [![Node](https://img.shields.io/badge/Node-22%2B-brightgreen.svg)](https://nodejs.org/)
9
+
10
+ <!-- translated-from: README.md sha256:a490558a910c -->
11
+
12
+ A subtitle plugin for DeepSeek Harness (DSH) that turns Japanese video into bilingual
13
+ Japanese/Chinese SRT files. The plugin installs every runtime component it needs
14
+ (ffmpeg, CPython, PyTorch, transformers) into one directory; no preinstalled Python,
15
+ ffmpeg or model is required.
16
+
17
+ ```
18
+ video/audio ──ffmpeg──▶ 16 kHz wav ──energy VAD + Whisper──▶ asr.json (one entry per utterance, with start and end)
19
+ ──segmentation──▶ cues.json (fragment ranges, editable) ──coverage check──▶ subtitles.srt
20
+ ```
21
+
22
+ ## Features
23
+
24
+ - **Self-contained runtime**: static ffmpeg and ffprobe, CPython 3.12, a virtual
25
+ environment, PyTorch (CUDA 12.8) and transformers, all inside one directory. Deleting
26
+ that directory uninstalls everything.
27
+ - **Measured download sources**: ffmpeg, Python, PyPI and the model host are probed once
28
+ per install. A global source is used only when it is at least 1.5× faster; otherwise
29
+ the domestic mirror is kept.
30
+ - **Japanese ASR**: kotoba-whisper-v2.0 with energy-VAD segmentation. CUDA falls back to
31
+ CPU when unavailable, and the log records why.
32
+ - **Background jobs**: progress, phase and a log tail. A running job can be cancelled,
33
+ which terminates the whole process tree.
34
+ - **Projects**: pin, hide, and delete either the reference or the local files.
35
+ - **Cue editing**: edit the Japanese and Chinese text, split a cue, merge it with the
36
+ next one, adjust either edge in 0.1 s steps, or restore derived timing.
37
+ - **SRT export**: UTF-8 BOM with CRLF line endings, validated against fragment coverage.
38
+ - **Automatic translation**: batches go to the model already configured in DSH, with the glossary and your notes; a manual paste path remains when no model is available.
39
+ - **Background and glossary**: project-level tags and a note join every translation prompt; the
40
+ glossary imports and exports as CSV and rewrites misheard names deterministically.
41
+ - **Japanese proofreading**: an optional pass corrects ASR errors (homophones, dropped words,
42
+ broken sentences) before translating and reports how many lines changed.
43
+ - **Projects folder**: defaults to Documents, can be moved with the existing projects, and opens
44
+ in the file manager from the panel.
45
+ - **Recent files**: the media picker expands into recent files and folders.
46
+ - **Line deletion**: deleting a cue marks it as skipped, so coverage and export stay valid.
47
+ - **File browser**: in-app picker with quick locations that remembers the last directory.
48
+
49
+ Not implemented yet: ASS export with styling.
50
+
51
+ ## Installation
52
+
53
+ ```sh
54
+ dsh plugin --profile <profile> add dsh-ai-subtitle
55
+ ```
56
+
57
+ Desktop users can also install it from **Plugins → Add plugin**. The plugin id is `dsh-ai-subtitle`;
58
+ after installation the "字幕工作台" entry appears in the left navigation.
59
+
60
+ To install from a local checkout:
61
+
62
+ ```sh
63
+ dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
64
+ ```
65
+
66
+ This repository is also a DSH bundle, declared by `dsh.bundle.patch` in `package.json` and
67
+ `cordis.patch.yml`.
68
+ ## Panel
69
+
70
+ The panel is registered as a DSH main panel and a left-navigation entry, and also
71
+ provides a settings section and a right-sidebar tab. From top to bottom:
72
+
73
+ - **Status**: runtime directory, readiness, and one badge per component (green installed
74
+ by this plugin, blue external path, amber missing). Clicking a badge reinstalls the
75
+ component or points it at an existing directory; components installed by this plugin
76
+ carry `×` and can be removed individually.
77
+ - **Runtime** (collapsed by default): install and repair, optional model download,
78
+ migration, and the download sources with their measured speed (re-probe on demand).
79
+ - **Transcribe**: media path with a **Browse** button, then start.
80
+ - **Tasks**: progress bar, phase, log tail, and a **Cancel** button while running.
81
+ - **Projects**: pin, show removed, change or open the projects folder, delete (reference only or with the local files). Opening
82
+ a project shows a dialog for SRT export, `cues.json` import, cue editing and preview.
83
+
84
+ ## Agent tools
85
+
86
+ | Tool | Purpose |
87
+ |---|---|
88
+ | `subtitle_status` | runtime directory, component state, recent jobs |
89
+ | `subtitle_install` | install or repair the runtime (`installDir`, `withModel`) |
90
+ | `subtitle_transcribe` | transcribe a video or audio file into `asr.json` |
91
+ | `subtitle_job` | job progress and result (`waitSeconds` blocks) |
92
+ | `subtitle_export` | build the bilingual SRT from `asr.json` and cue files (coverage validated) |
93
+ | `subtitle_review` | batch review: take a batch, apply the returned lines, validate coverage and glossary ([docs/REVIEW.md](docs/REVIEW.md)) |
94
+ | `subtitle_glossary` | glossary: show, export to CSV, import and merge from a file or an online URL |
95
+
96
+ ## Data and routes
97
+
98
+ The panel reads a local JSON API under `/dsh-ai-subtitle/api/…`: `status`, `job`,
99
+ `job/cancel`, `projects`, `project`, `install`, `transcribe`, `pin`, `restore`, `delete`,
100
+ `import-cues`, `save-cues`, `export`, `fs/list`, `fs/places`, `fs/pick`, `runtime/probe`,
101
+ `runtime/remove`, `runtime/use-path`, `runtime/clear-path`, `runtime/migrate`, `debug`.
102
+ These routes listen on localhost only and bypass the DSH `/api` peer authentication, so
103
+ they are intended for local use.
104
+
105
+ ## Runtime directory
106
+
107
+ The default is `%LOCALAPPDATA%\DshSubtitle`; another directory can be chosen at install
108
+ time.
109
+
110
+ ```
111
+ <root>/
112
+ bin/ ffmpeg.exe ffprobe.exe
113
+ python/ CPython 3.12 installed by the official installer
114
+ venv/ virtual environment (torch, transformers)
115
+ models/ Hugging Face cache (HF_HOME)
116
+ projects/ one directory per transcription: audio.wav, asr.json, meta.json, cues.json, subtitles.srt
117
+ cache/ download cache
118
+ logs/ client.log (panel diagnostics)
119
+ state.json download sources, backend, CUDA probe, path overrides, last project
120
+ registry.json project pin and hide state
121
+ runtime.json marker set by this plugin
122
+ ```
123
+
124
+ All large dependencies live inside `<root>`, so deleting that directory uninstalls the
125
+ runtime. The plugin does not write the DSH profile and does not modify an existing Python
126
+ installation. A migration leaves a pointer to the new location at
127
+ `%LOCALAPPDATA%\DshSubtitle.location.json`.
128
+
129
+ ## Command-line helpers
130
+
131
+ `scripts/` contains helpers that work outside DSH:
132
+
133
+ - `install-cli.js`: `node scripts/install-cli.js [root] [--with-model]` runs the installer;
134
+ - `build_srt.js`, `qa_cues.js`: export or check an SRT from `asr.json` and cue files;
135
+ - `split_fragments.py`: slice fragments into chunks for batch proofreading;
136
+ - `patch_cues.js`: deterministic edits driven by a `patch.json`, keeping project text out
137
+ of the code;
138
+ - `check-client.mjs`: checks `client.js` syntax and compares its top-level declarations
139
+ against a snapshot, so a removed declaration cannot silently break the panel.
140
+
141
+ ## Limitations
142
+
143
+ - **Windows only**: the ffmpeg package and path handling assume Windows.
144
+ - **Segment timestamps**: `return_timestamps="word"` raises `IndexError` with
145
+ transformers 5.x and this model, so each fragment has a start and end but no per-word
146
+ timing.
147
+ - **Translation uses the configured model**: the plugin calls the DSH model service, so no extra
148
+ API key is needed; a manual paste path remains when no model is available.
149
+ - **Panel language**: the panel ships in Simplified Chinese only; the plugin entry title and
150
+ description are translated (English and Chinese).
151
+ - The first install downloads about 3 GB (the CUDA build and the model) and needs a stable
152
+ network.
153
+
154
+ ## Development
155
+
156
+ `/plugins/<package>/client.js` is served with an immutable cache whose revision comes from
157
+ the file mtime and size, so after editing `client.js` the plugin must be reloaded
158
+ (`remove_bundle` + `install_bundle`, or a DSH restart); a browser refresh alone keeps the
159
+ old bundle. The `ui-…` tag in the panel header shows which build is running.
160
+
161
+ The roadmap is in [docs/PLAN.md](docs/PLAN.md).
162
+
163
+ ## License
164
+
165
+ MIT. Runtime components keep their own licenses: ffmpeg (npm-mirror static package or
166
+ gyan.dev), CPython (PSF), PyTorch (BSD-3), transformers (Apache-2.0). The default model
167
+ [`kotoba-tech/kotoba-whisper-v2.0`](https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0)
168
+ is covered by its model card.
package/README.ja.md ADDED
@@ -0,0 +1,128 @@
1
+ # dsh-ai-subtitle
2
+
3
+ **日本語** · [简体中文](README.md) · [English](README.en.md) · [한국어](README.ko.md)
4
+
5
+ [![hygiene](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml/badge.svg)](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![npm](https://img.shields.io/npm/v/dsh-ai-subtitle.svg)](https://www.npmjs.com/package/dsh-ai-subtitle)
8
+ [![Node](https://img.shields.io/badge/Node-22%2B-brightgreen.svg)](https://nodejs.org/)
9
+
10
+ <!-- translated-from: README.md sha256:a490558a910c -->
11
+
12
+ DeepSeek Harness(DSH)の字幕プラグインです。日本語動画を日中バイリンガルの SRT に変換します。必要なランタイム(ffmpeg、CPython、PyTorch、transformers)は指定ディレクトリにすべて導入されるため、Python・ffmpeg・モデルを事前に用意する必要はありません。
13
+
14
+ ```
15
+ 動画/音声 ──ffmpeg──▶ 16 kHz wav ──エネルギーVAD + Whisper──▶ asr.json(発話ごとに1件、開始・終了時刻つき)
16
+ ──文分割──▶ cues.json(フラグメント範囲、編集可能)──▶ 被覆検証 ──▶ subtitles.srt
17
+ ```
18
+
19
+ ## 機能
20
+
21
+ - **ランタイム自動導入**:静的 ffmpeg と ffprobe、CPython 3.12、仮想環境、PyTorch(CUDA 12.8)、transformers を 1 つのディレクトリに導入します。そのディレクトリを削除すればアンインストール完了です。
22
+ - **ダウンロード元の実測**:ffmpeg、Python、PyPI、モデルの 4 系統を導入時に測定し、国際ソースは実測で 1.5 倍以上速い場合のみ使用します。それ以外は国内ミラーを使います。
23
+ - **日本語認識**:kotoba-whisper-v2.0 を使用し、エネルギー VAD で音声区間を先に分割します。CUDA が使えない場合は CPU に切り替え、その理由をログに残します。
24
+ - **バックグラウンド処理**:進捗、フェーズ、ログ末尾を表示します。実行中のタスクはキャンセルでき、プロセスツリー全体を終了します。
25
+ - **プロジェクト管理**:ピン留め、非表示、参照のみ削除・ローカルファイルごと削除の 2 種類。
26
+ - **キュー編集**:日本語と中国語のテキスト編集、分割、次のキューとの結合、開始・終了時刻の 0.1 秒調整、自動時刻への復元。
27
+ - **SRT 出力**:UTF-8 BOM と CRLF、出力前にフラグメント被覆を検証します。
28
+ - **自動翻訳**:DSH に設定済みのモデルへバッチ単位で送信し、用語集とあなたの意見を添えます。モデルが使えない場合は手動貼り付けも可能です。
29
+ - **背景と用語**:プロジェクト単位のタグと説明を毎回の翻訳プロンプトに含めます。用語集は CSV で入出力でき、聞き間違いの修正にも対応します。
30
+ - **日本語の校正**:翻訳前に認識誤り(同音異義語・抜け・句切り)を校正でき、変更件数を報告します。
31
+ - **プロジェクトフォルダー**:既定は「ドキュメント」配下。変更と既存プロジェクトの移行ができ、エクスプローラーで開けます。
32
+ - **最近使った項目**:メディア選択時に最近のファイルとフォルダーを展開できます。
33
+ - **行の削除**:不要な行は削除(内部的にはスキップ)でき、カバレッジと書き出しに影響しません。
34
+ - **ファイル参照**:内蔵ブラウザ。クイック位置を備え、前回のディレクトリを記憶します。
35
+
36
+ 未実装:ASS 出力(スタイル付き字幕)。
37
+
38
+ ## 導入
39
+
40
+ ```sh
41
+ dsh plugin --profile <profile> add dsh-ai-subtitle
42
+ ```
43
+
44
+ デスクトップ版では **Plugins → Add plugin** からも導入できます。プラグイン id は `dsh-ai-subtitle` です。
45
+ 導入後、左ナビゲーションに「字幕工作台」が表示されます。
46
+
47
+ ローカルのチェックアウトから導入する場合:
48
+
49
+ ```sh
50
+ dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
51
+ ```
52
+
53
+ 本リポジトリは DSH bundle でもあり、`package.json` の `dsh.bundle.patch` と `cordis.patch.yml`
54
+ で宣言しています。
55
+ ## パネル
56
+
57
+ DSH のメインパネルと左ナビゲーションの項目として登録され、設定セクションと右サイドバーのタブも提供します。上から順に:
58
+
59
+ - **状態**:ランタイムのディレクトリ、準備状況、コンポーネントごとのバッジ(緑は本プラグインが導入、青は外部パス、黄は未導入)。バッジをクリックすると再導入または既存ディレクトリの指定ができ、本プラグインが導入したものは `×` で個別に削除できます。
60
+ - **ランタイム**(既定では折りたたみ):導入と修復、モデルの同時取得、全体の移行、ダウンロード元と実測速度(再測定可能)。
61
+ - **文字起こし**:メディアのパスと「参照」ボタン。
62
+ - **タスク**:進捗バー、フェーズ、ログ末尾。実行中は「キャンセル」。
63
+ - **プロジェクト**:ピン留め、非表示の表示、削除(参照のみ、またはローカルファイルごと)。プロジェクトを開くとダイアログで SRT 出力、`cues.json` の取り込み、キュー編集とプレビューができます。
64
+
65
+ ## エージェント向けツール
66
+
67
+ | ツール | 役割 |
68
+ |---|---|
69
+ | `subtitle_status` | ランタイムのディレクトリ、コンポーネントの状態、最近のタスク |
70
+ | `subtitle_install` | ランタイムの導入または修復(`installDir`、`withModel`) |
71
+ | `subtitle_transcribe` | 動画または音声を `asr.json` に書き出す |
72
+ | `subtitle_job` | タスクの進捗と結果(`waitSeconds` で待機) |
73
+ | `subtitle_export` | `asr.json` とキュー定義から SRT を出力(被覆を検証) |
74
+ | `subtitle_review` | バッチ校正:バッチ取得、返却行の反映、被覆と用語の検証([docs/REVIEW.md](docs/REVIEW.md)) |
75
+ | `subtitle_glossary` | 用語集:表示、CSV 出力、ファイルまたはオンライン URL から取り込み・統合 |
76
+
77
+ ## データと API
78
+
79
+ パネルはローカルの JSON API(`/dsh-ai-subtitle/api/…`)を使用します:`status`、`job`、`job/cancel`、`projects`、`project`、`install`、`transcribe`、`pin`、`restore`、`delete`、`import-cues`、`save-cues`、`export`、`fs/list`、`fs/places`、`fs/pick`、`runtime/probe`、`runtime/remove`、`runtime/use-path`、`runtime/clear-path`、`runtime/migrate`、`debug`。これらのルートは localhost のみで待ち受け、DSH の `/api` 認証を通りません。ローカル利用を前提としています。
80
+
81
+ ## ランタイムのディレクトリ
82
+
83
+ 既定は `%LOCALAPPDATA%\DshSubtitle` で、導入時に別のディレクトリを指定できます。
84
+
85
+ ```
86
+ <root>/
87
+ bin/ ffmpeg.exe ffprobe.exe
88
+ python/ 公式インストーラで導入した CPython 3.12
89
+ venv/ 仮想環境(torch、transformers)
90
+ models/ Hugging Face のキャッシュ(HF_HOME)
91
+ projects/ 文字起こしごとのディレクトリ:audio.wav、asr.json、meta.json、cues.json、subtitles.srt
92
+ cache/ ダウンロードのキャッシュ
93
+ logs/ client.log(パネルの診断ログ)
94
+ state.json ダウンロード元、バックエンド、CUDA の測定結果、パスの上書き、前回のプロジェクト
95
+ registry.json ピン留めと非表示の状態
96
+ runtime.json 本プラグインが導入したことを示すマーカー
97
+ ```
98
+
99
+ 大きな依存はすべて `<root>` 内にあり、削除すればアンインストールできます。DSH のプロファイルには書き込まず、既存の Python 環境も変更しません。移行後は新しい場所を指すポインタを `%LOCALAPPDATA%\DshSubtitle.location.json` に残します。
100
+
101
+ ## コマンドラインツール
102
+
103
+ `scripts/` には DSH なしで使える補助スクリプトがあります:
104
+
105
+ - `install-cli.js`:`node scripts/install-cli.js [root] [--with-model]` でインストーラを実行;
106
+ - `build_srt.js`、`qa_cues.js`:`asr.json` とキュー定義から SRT を出力・検証;
107
+ - `split_fragments.py`:フラグメントを分割して分割校正に回す;
108
+ - `patch_cues.js`:`patch.json` に基づく決定的な削除・置換(プロジェクトのテキストをコードから分離);
109
+ - `check-client.mjs`:`client.js` の構文とトップレベル宣言のスナップショットを照合し、宣言の消失によるパネル不動作を防ぎます。
110
+
111
+ ## 既知の制限
112
+
113
+ - **Windows のみ**:ffmpeg のパッケージとパス処理は Windows を前提としています。
114
+ - **区間単位の時刻**:transformers 5.x と kotoba-whisper の `return_timestamps="word"` は `IndexError` を送出するため、フラグメントごとの開始・終了時刻のみで、単語単位の時刻はありません。
115
+ - **翻訳は設定済みモデルに依存**:DSH のモデルサービスを呼ぶため API key の追加設定は不要です。
116
+ モデルが使えない場合は手動貼り付けに切り替えられます。
117
+ - **パネルの言語**:パネルは簡体字中国語のみです。プラグイン入口のタイトルと説明は英語・中国語の二言語です。
118
+ - 初回導入は約 3 GB(CUDA 版 PyTorch とモデル)で、安定した回線が必要です。
119
+
120
+ ## 開発
121
+
122
+ `/plugins/<package>/client.js` は immutable キャッシュで配信され、revision はファイルの mtime とサイズから決まります。`client.js` を変更したらプラグインを再読み込み(`remove_bundle` + `install_bundle`、または DSH の再起動)してください。ページを再読み込みするだけでは古い bundle が使われます。パネル上部の `ui-…` が実行中のビルドです。
123
+
124
+ 今後の予定は [docs/PLAN.md](docs/PLAN.md) にあります。
125
+
126
+ ## ライセンス
127
+
128
+ MIT。ランタイムの構成要素はそれぞれのライセンスに従います:ffmpeg(npm ミラーの静的パッケージまたは gyan.dev)、CPython(PSF)、PyTorch(BSD-3)、transformers(Apache-2.0)。既定モデル [`kotoba-tech/kotoba-whisper-v2.0`](https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0) はモデルカードに従います。
package/README.ko.md ADDED
@@ -0,0 +1,128 @@
1
+ # dsh-ai-subtitle
2
+
3
+ **한국어** · [简体中文](README.md) · [English](README.en.md) · [日本語](README.ja.md)
4
+
5
+ [![hygiene](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml/badge.svg)](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![npm](https://img.shields.io/npm/v/dsh-ai-subtitle.svg)](https://www.npmjs.com/package/dsh-ai-subtitle)
8
+ [![Node](https://img.shields.io/badge/Node-22%2B-brightgreen.svg)](https://nodejs.org/)
9
+
10
+ <!-- translated-from: README.md sha256:a490558a910c -->
11
+
12
+ DeepSeek Harness(DSH)용 자막 플러그인으로, 일본어 영상을 일중 이중 언어 SRT로 변환합니다. 필요한 런타임(ffmpeg, CPython, PyTorch, transformers)은 지정한 디렉터리에 모두 설치되므로 Python, ffmpeg, 모델을 미리 준비할 필요가 없습니다.
13
+
14
+ ```
15
+ 영상/오디오 ──ffmpeg──▶ 16 kHz wav ──에너지 VAD + Whisper──▶ asr.json (발화마다 1건, 시작·종료 시각 포함)
16
+ ──문장 분할──▶ cues.json (프래그먼트 구간, 편집 가능) ──커버리지 검증──▶ subtitles.srt
17
+ ```
18
+
19
+ ## 기능
20
+
21
+ - **런타임 자동 설치**: 정적 ffmpeg와 ffprobe, CPython 3.12, 가상 환경, PyTorch(CUDA 12.8), transformers를 하나의 디렉터리에 설치합니다. 그 디렉터리를 삭제하면 완전히 제거됩니다.
22
+ - **다운로드 소스 측정**: ffmpeg, Python, PyPI, 모델 네 갈래를 설치 시 한 번씩 측정합니다. 국제 소스는 실측으로 1.5배 이상 빠를 때만 사용하고, 그 외에는 국내 미러를 유지합니다.
23
+ - **일본어 인식**: kotoba-whisper-v2.0을 사용하며 에너지 VAD로 음성 구간을 먼저 나눕니다. CUDA를 사용할 수 없으면 CPU로 대체하고 그 이유를 로그에 남깁니다.
24
+ - **백그라운드 작업**: 진행률, 단계, 로그 끝부분을 표시합니다. 실행 중인 작업은 취소할 수 있으며 프로세스 트리 전체를 종료합니다.
25
+ - **프로젝트 관리**: 고정, 숨김, 참조만 삭제 또는 로컬 파일까지 삭제의 두 가지 방식.
26
+ - **큐 편집**: 일본어와 중국어 텍스트 수정, 분할, 다음 큐와 병합, 시작·종료 시각을 0.1초 단위로 조정, 자동 시각 복원.
27
+ - **SRT 내보내기**: UTF-8 BOM과 CRLF를 사용하며, 내보내기 전에 프래그먼트 커버리지를 검증합니다.
28
+ - **자동 번역**: DSH에 설정된 모델로 배치를 보내며 용어집과 사용자 의견을 함께 전달합니다. 모델을 쓸 수 없으면 수동 붙여넣기도 가능합니다.
29
+ - **배경과 용어**: 프로젝트 단위 태그와 설명이 매번 번역 프롬프트에 포함됩니다. 용어집은 CSV로 가져오기/내보내기가 가능하며 잘못 들은 이름도 수정합니다.
30
+ - **일본어 교정**: 번역 전에 인식 오류(동음어, 누락, 끊어 읽기)를 교정하고 변경된 줄 수를 보고합니다.
31
+ - **프로젝트 폴더**: 기본은 "문서" 폴더이며 변경과 기존 프로젝트 이동을 지원하고 탐색기에서 열 수 있습니다.
32
+ - **최근 사용**: 미디어 선택 시 최근 파일과 폴더를 펼쳐 볼 수 있습니다.
33
+ - **줄 삭제**: 필요 없는 줄을 삭제(내부적으로 건너뛰기)해도 커버리지와 내보내기에 영향이 없습니다.
34
+ - **파일 찾아보기**: 내장 브라우저로 빠른 위치를 제공하고 마지막 디렉터리를 기억합니다.
35
+
36
+ 미구현: ASS 내보내기(스타일 자막).
37
+
38
+ ## 설치
39
+
40
+ ```sh
41
+ dsh plugin --profile <profile> add dsh-ai-subtitle
42
+ ```
43
+
44
+ 데스크톱에서는 **Plugins → Add plugin**에서도 설치할 수 있습니다. 플러그인 id는 `dsh-ai-subtitle`이며,
45
+ 설치 후 왼쪽 내비게이션에 「字幕工作台」가 나타납니다.
46
+
47
+ 로컬 체크아웃에서 설치하려면:
48
+
49
+ ```sh
50
+ dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
51
+ ```
52
+
53
+ 이 저장소는 DSH 번들이기도 하며, `package.json`의 `dsh.bundle.patch`와 `cordis.patch.yml`로
54
+ 선언합니다.
55
+ ## 패널
56
+
57
+ DSH의 메인 패널과 왼쪽 내비게이션 항목으로 등록되며, 설정 섹션과 오른쪽 사이드바 탭도 제공합니다. 위에서 아래로:
58
+
59
+ - **상태**: 런타임 디렉터리, 준비 여부, 컴포넌트별 배지(초록은 이 플러그인이 설치, 파랑은 외부 경로, 노랑은 없음). 배지를 누르면 재설치하거나 기존 디렉터리를 지정할 수 있고, 이 플러그인이 설치한 것은 `×`로 개별 삭제할 수 있습니다.
60
+ - **런타임**(기본 접힘): 설치와 복구, 모델 동시 다운로드, 전체 이전, 다운로드 소스와 측정 속도(다시 측정 가능).
61
+ - **전사**: 미디어 경로와 「찾아보기」 버튼.
62
+ - **작업**: 진행률 표시줄, 단계, 로그 끝부분. 실행 중에는 「취소」.
63
+ - **프로젝트**: 고정, 숨김 표시, 삭제(참조만 또는 로컬 파일까지). 프로젝트를 열면 대화상자에서 SRT 내보내기, `cues.json` 가져오기, 큐 편집과 미리보기를 사용할 수 있습니다.
64
+
65
+ ## 에이전트 도구
66
+
67
+ | 도구 | 역할 |
68
+ |---|---|
69
+ | `subtitle_status` | 런타임 디렉터리, 컴포넌트 상태, 최근 작업 |
70
+ | `subtitle_install` | 런타임 설치 또는 복구(`installDir`, `withModel`) |
71
+ | `subtitle_transcribe` | 영상 또는 오디오를 `asr.json`으로 전사 |
72
+ | `subtitle_job` | 작업 진행률과 결과(`waitSeconds`로 대기) |
73
+ | `subtitle_export` | `asr.json`과 큐 파일로 SRT 내보내기(커버리지 검증) |
74
+ | `subtitle_review` | 배치 교정: 배치 가져오기, 반환된 줄 반영, 커버리지·용어 검증([docs/REVIEW.md](docs/REVIEW.md)) |
75
+ | `subtitle_glossary` | 용어집: 조회, CSV 내보내기, 파일 또는 온라인 URL에서 가져와 병합 |
76
+
77
+ ## 데이터와 API
78
+
79
+ 패널은 로컬 JSON API(`/dsh-ai-subtitle/api/…`)를 사용합니다: `status`, `job`, `job/cancel`, `projects`, `project`, `install`, `transcribe`, `pin`, `restore`, `delete`, `import-cues`, `save-cues`, `export`, `fs/list`, `fs/places`, `fs/pick`, `runtime/probe`, `runtime/remove`, `runtime/use-path`, `runtime/clear-path`, `runtime/migrate`, `debug`. 이 경로들은 localhost에서만 대기하며 DSH의 `/api` 인증을 거치지 않습니다. 로컬 사용을 전제로 합니다.
80
+
81
+ ## 런타임 디렉터리
82
+
83
+ 기본값은 `%LOCALAPPDATA%\DshSubtitle`이며 설치할 때 다른 디렉터리를 지정할 수 있습니다.
84
+
85
+ ```
86
+ <root>/
87
+ bin/ ffmpeg.exe ffprobe.exe
88
+ python/ 공식 설치 프로그램으로 설치한 CPython 3.12
89
+ venv/ 가상 환경(torch, transformers)
90
+ models/ Hugging Face 캐시(HF_HOME)
91
+ projects/ 전사마다 하나의 디렉터리: audio.wav, asr.json, meta.json, cues.json, subtitles.srt
92
+ cache/ 다운로드 캐시
93
+ logs/ client.log(패널 진단 로그)
94
+ state.json 다운로드 소스, 백엔드, CUDA 측정 결과, 경로 재정의, 마지막 프로젝트
95
+ registry.json 고정과 숨김 상태
96
+ runtime.json 이 플러그인이 설치했다는 표식
97
+ ```
98
+
99
+ 큰 의존성은 모두 `<root>` 안에 있어 그 디렉터리를 삭제하면 완전히 제거됩니다. DSH 프로필에 쓰지 않고 기존 Python 환경도 변경하지 않습니다. 이전 후에는 새 위치를 가리키는 포인터를 `%LOCALAPPDATA%\DshSubtitle.location.json`에 남깁니다.
100
+
101
+ ## 명령줄 도구
102
+
103
+ `scripts/`에는 DSH 없이 사용할 수 있는 보조 스크립트가 있습니다:
104
+
105
+ - `install-cli.js`: `node scripts/install-cli.js [root] [--with-model]`로 설치 프로그램을 실행;
106
+ - `build_srt.js`, `qa_cues.js`: `asr.json`과 큐 파일로 SRT를 내보내거나 검증;
107
+ - `split_fragments.py`: 프래그먼트를 여러 조각으로 나눠 배치 교정에 사용;
108
+ - `patch_cues.js`: `patch.json`에 따른 결정적 삭제·치환(프로젝트 텍스트를 코드와 분리);
109
+ - `check-client.mjs`: `client.js` 구문과 최상위 선언 스냅숏을 대조해 선언 누락으로 패널이 렌더링되지 않는 일을 방지합니다.
110
+
111
+ ## 알려진 제한
112
+
113
+ - **Windows 전용**: ffmpeg 패키지와 경로 처리가 Windows를 전제로 합니다.
114
+ - **구간 단위 시각**: transformers 5.x와 kotoba-whisper의 `return_timestamps="word"`는 `IndexError`를 발생시키므로 프래그먼트마다 시작·종료 시각만 있고 단어 단위 시각은 없습니다.
115
+ - **번역은 설정된 모델 사용**: DSH 모델 서비스를 호출하므로 추가 API key가 필요 없습니다.
116
+ 모델을 쓸 수 없으면 수동 붙여넣기로 전환할 수 있습니다.
117
+ - **패널 언어**: 패널은 현재 중국어 간체만 지원합니다. 플러그인 진입점의 제목과 설명은 영어/중국어 두 가지입니다.
118
+ - 첫 설치에 약 3 GB(CUDA 빌드와 모델)를 내려받으며 안정적인 회선이 필요합니다.
119
+
120
+ ## 개발
121
+
122
+ `/plugins/<package>/client.js`는 immutable 캐시로 제공되며 revision은 파일 mtime과 크기에서 결정됩니다. `client.js`를 수정한 뒤에는 플러그인을 다시 로드(`remove_bundle` + `install_bundle`, 또는 DSH 재시작)해야 합니다. 페이지를 새로 고치는 것만으로는 이전 번들이 계속 사용됩니다. 패널 상단의 `ui-…` 표식이 현재 빌드입니다.
123
+
124
+ 앞으로의 계획은 [docs/PLAN.md](docs/PLAN.md)에 있습니다.
125
+
126
+ ## 라이선스
127
+
128
+ MIT. 런타임 구성 요소는 각자의 라이선스를 따릅니다: ffmpeg(npm 미러 정적 패키지 또는 gyan.dev), CPython(PSF), PyTorch(BSD-3), transformers(Apache-2.0). 기본 모델 [`kotoba-tech/kotoba-whisper-v2.0`](https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0)은 모델 카드를 따릅니다.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
1
+ # dsh-ai-subtitle
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **简体中文** · [English](README.en.md) · [日本語](README.ja.md) · [한국어](README.ko.md)
4
+
5
+ [![hygiene](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml/badge.svg)](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![npm](https://img.shields.io/npm/v/dsh-ai-subtitle.svg)](https://www.npmjs.com/package/dsh-ai-subtitle)
8
+ [![Node](https://img.shields.io/badge/Node-22%2B-brightgreen.svg)](https://nodejs.org/)
9
+
10
+ DeepSeek Harness(DSH)的字幕插件,把日语视频转成中日双语 SRT。插件在指定目录内安装所需的全部运行时(ffmpeg、CPython、PyTorch、transformers),无需预先安装 Python、ffmpeg 或模型。
11
+
12
+ ```
13
+ 视频/音频 ──ffmpeg──▶ 16 kHz wav ──能量 VAD + Whisper──▶ asr.json(每句一条,含起止时间)
14
+ ──分句──▶ cues.json(碎片区间,可编辑)──▶ 覆盖率校验 ──▶ subtitles.srt
15
+ ```
16
+
17
+ ## 功能
18
+
19
+ - **运行时自举**:静态 ffmpeg 与 ffprobe、CPython 3.12、虚拟环境、PyTorch(CUDA 12.8)与 transformers,全部位于指定目录内;删除该目录即完成卸载。
20
+ - **下载源测速**:ffmpeg、Python、PyPI、模型四组各测一次,仅当国际源实际快 1.5 倍以上时启用,否则使用国内镜像。
21
+ - **日语识别**:kotoba-whisper-v2.0,能量 VAD 先切分语音段,CUDA 不可用时回退 CPU 并在日志中说明。
22
+ - **后台任务**:显示进度、阶段与日志尾部;运行中的任务可以取消,取消会终止整个进程树。
23
+ - **项目管理**:置顶、隐藏;删除时可选仅移除引用或连同本地文件删除。
24
+ - **cue 编辑**:修改日文与中文、拆分、与下一条合并、起止时间按 0.1 秒调整、恢复自动时间。
25
+ - **SRT 导出**:UTF-8 BOM 与 CRLF 行尾,导出前校验碎片覆盖率。
26
+ - **自动翻译**:按批调用 DSH 已配置的模型,带上术语表与你的意见;模型不可用时仍可手动粘贴译文。
27
+ - **背景与术语**:项目级标签与说明会随每次翻译进入提示词;术语表可导入导出 CSV,并支持误听修正。
28
+ - **校对日文**:翻译前可选校正识别错误(同音字、漏字、断句),并报告改动了多少条。
29
+ - **项目目录**:默认在「文档」下,可自定义并迁移现有项目;可一键在资源管理器中打开。
30
+ - **最近使用**:浏览媒体时可展开最近用过的文件与文件夹。
31
+ - **逐条删除**:不需要的行直接删除(内部记为跳过段),不影响覆盖率与导出。
32
+ - **文件浏览**:内置文件浏览器,提供快捷位置并记住上次访问的目录。
33
+
34
+ 尚未实现:ASS 导出(带样式的字幕)。
35
+
36
+ ## 安装
37
+
38
+ ```sh
39
+ dsh plugin --profile <profile> add dsh-ai-subtitle
40
+ ```
41
+
42
+ 桌面用户也可以在 **Plugins → Add plugin** 中安装。插件 id 为 `dsh-ai-subtitle`,安装后左侧导航出现「字幕工作台」。
43
+
44
+ 从本地检出安装:
45
+
46
+ ```sh
47
+ dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
48
+ ```
49
+
50
+ 本仓库同时是 DSH bundle,由 `package.json` 的 `dsh.bundle.patch` 与 `cordis.patch.yml` 声明。
51
+ ## 界面
52
+
53
+ 面板注册为 DSH 主面板与左侧导航入口,同时提供设置分区和右侧栏标签。自上而下:
54
+
55
+ - **状态**:运行时目录、是否就绪、各组件徽章(绿色为本插件安装、蓝色为外部路径、黄色为缺失)。点击徽章可重新安装或指定已有目录;本插件安装的组件带 `×`,可单独删除。
56
+ - **运行时**(默认折叠):安装与修复、是否同时下载模型、整体迁移、下载源及其测得速率(可重新测速)。
57
+ - **转写**:媒体路径与「浏览」按钮,随后开始转写。
58
+ - **任务**:进度条、阶段、日志尾部;运行中的任务右侧有「取消」。
59
+ - **项目**:置顶、显示已移除、删除(仅移除引用或连本地文件一起删除),可更改或打开项目目录;打开项目后可在弹窗中自动翻译、逐条修改(含删除)、导出字幕。
60
+
61
+ ## Agent 工具
62
+
63
+ | 工具 | 作用 |
64
+ |---|---|
65
+ | `subtitle_status` | 运行时目录、各组件状态、最近任务 |
66
+ | `subtitle_install` | 安装或修复运行时(`installDir`、`withModel`) |
67
+ | `subtitle_transcribe` | 转写视频或音频,产出 `asr.json` |
68
+ | `subtitle_job` | 查询任务进度与结果(`waitSeconds` 可阻塞等待) |
69
+ | `subtitle_export` | 由 `asr.json` 与 cue 文件导出双语 SRT(校验覆盖率) |
70
+ | `subtitle_review` | 分批校对:取批次、回填译文、校验覆盖率与术语(见 [docs/REVIEW.md](docs/REVIEW.md)) |
71
+ | `subtitle_glossary` | 术语表:查看、导出为 CSV、从文件或在线链接导入并合并 |
72
+
73
+ ## 数据与接口
74
+
75
+ 面板通过本地 JSON 路由取数(`/dsh-ai-subtitle/api/…`):`status`、`job`、`job/cancel`、`projects`、`project`、`install`、`transcribe`、`pin`、`restore`、`delete`、`import-cues`、`save-cues`、`export`、`fs/list`、`fs/places`、`fs/pick`、`runtime/probe`、`runtime/remove`、`runtime/use-path`、`runtime/clear-path`、`runtime/migrate`、`debug`。这些路由仅监听本机,不经过 DSH 的 `/api` 鉴权,适用于本机使用。
76
+
77
+ ## 运行时目录
78
+
79
+ 默认 `%LOCALAPPDATA%\DshSubtitle`,安装时可指定其他目录。
80
+
81
+ ```
82
+ <root>/
83
+ bin/ ffmpeg.exe ffprobe.exe
84
+ python/ 官方安装器安装的 CPython 3.12
85
+ venv/ 虚拟环境(torch、transformers)
86
+ models/ Hugging Face 模型缓存(HF_HOME)
87
+ projects/ 每次转写一个目录:audio.wav、asr.json、meta.json、cues.json、subtitles.srt
88
+ cache/ 下载缓存
89
+ logs/ client.log(面板诊断日志)
90
+ state.json 下载源、后端、CUDA 探测结果、路径覆盖、上次项目
91
+ registry.json 项目置顶与隐藏状态
92
+ runtime.json 本插件安装标记
93
+ ```
94
+
95
+ 所有大体积依赖都位于 `<root>` 内,删除该目录即可完全卸载。插件不写入 DSH profile,也不修改用户已有的 Python 环境。迁移后会在 `%LOCALAPPDATA%\DshSubtitle.location.json` 留下指向新位置的指针。
96
+
97
+ ## 命令行工具
98
+
99
+ `scripts/` 下提供可脱离 DSH 使用的辅助脚本:
100
+
101
+ - `install-cli.js`:`node scripts/install-cli.js [root] [--with-model]`,直接运行安装器;
102
+ - `build_srt.js`、`qa_cues.js`:由 `asr.json` 与 cue 文件导出或校验 SRT;
103
+ - `split_fragments.py`:把碎片切成若干块,便于分批校对;
104
+ - `patch_cues.js`:按 `patch.json` 做确定性删改,使项目文本与代码分离;
105
+ - `check-client.mjs`:检查 `client.js` 语法并核对顶层声明快照,防止误删声明导致面板无法渲染。
106
+
107
+ ## 已知限制
108
+
109
+ - **仅 Windows**:ffmpeg 静态包与路径处理按 Windows 实现。
110
+ - **段级时间戳**:transformers 5.x 与 kotoba-whisper 的 `return_timestamps="word"` 会抛出 `IndexError`,因此每条碎片只有起止时间,没有逐词时间。
111
+ - **翻译依赖已配置的模型**:插件通过 DSH 的模型服务自动翻译,不需要另外配置 API key;模型不可用时仍可手动粘贴。
112
+ - **界面语言**:面板目前只有简体中文;插件入口的标题与说明提供中英两版。
113
+ - 首次安装约 3 GB(CUDA 版 PyTorch 与模型),需要稳定网络。
114
+
115
+ ## 开发
116
+
117
+ `/plugins/<package>/client.js` 以 immutable 缓存提供,revision 取自文件 mtime 与大小,因此修改 `client.js` 后必须重新加载插件(`remove_bundle` + `install_bundle`,或重启 DSH);仅刷新页面会继续使用旧 bundle。面板标题中的 `ui-…` 标记可用于确认当前运行的版本。
118
+
119
+ 后续计划见 [docs/PLAN.md](docs/PLAN.md)。
120
+
121
+ ## 许可
122
+
123
+ MIT。运行时组件保留各自许可:ffmpeg(npm 镜像静态包或 gyan.dev)、CPython(PSF)、PyTorch(BSD-3)、transformers(Apache-2.0);默认模型 [`kotoba-tech/kotoba-whisper-v2.0`](https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0) 以模型卡为准。