dsh-ai-subtitle 0.0.0-stage → 0.2.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 +21 -0
- package/README.en.md +155 -0
- package/README.ja.md +118 -0
- package/README.ko.md +118 -0
- package/README.md +113 -2
- package/client.js +1449 -0
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +35 -0
- package/docs/PLAN.md +61 -0
- package/icon.svg +8 -0
- package/index.js +132 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +81 -4
- package/python/worker.py +212 -0
- package/scripts/build_srt.js +25 -0
- package/scripts/check-client.mjs +54 -0
- package/scripts/client-symbols.json +34 -0
- package/scripts/install-cli.js +27 -0
- package/scripts/patch_cues.js +52 -0
- package/scripts/qa_cues.js +42 -0
- package/scripts/split_fragments.py +26 -0
- package/src/api.js +539 -0
- package/src/cues.js +230 -0
- package/src/download.js +83 -0
- package/src/installer.js +339 -0
- package/src/jobs.js +100 -0
- package/src/paths.js +78 -0
- package/src/registry.js +39 -0
- package/src/runtime.js +376 -0
- package/src/sources.js +184 -0
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,155 @@
|
|
|
1
|
+
# dsh-ai-subtitle
|
|
2
|
+
|
|
3
|
+
**English** · [简体中文](README.md) · [日本語](README.ja.md) · [한국어](README.ko.md)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
|
|
10
|
+
<!-- translated-from: README.md sha256:74529e1fb540 -->
|
|
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
|
+
- **File browser**: in-app picker with quick locations that remembers the last directory.
|
|
39
|
+
|
|
40
|
+
Not implemented yet: glossary, automatic translation, ASS export.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile <profile> add dsh-ai-subtitle
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Desktop users can also install it from **Plugins → Add plugin**. The plugin id is `dsh-ai-subtitle`;
|
|
49
|
+
after installation the "字幕工作台" entry appears in the left navigation.
|
|
50
|
+
|
|
51
|
+
To install from a local checkout:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This repository is also a DSH bundle, declared by `dsh.bundle.patch` in `package.json` and
|
|
58
|
+
`cordis.patch.yml`.
|
|
59
|
+
## Panel
|
|
60
|
+
|
|
61
|
+
The panel is registered as a DSH main panel and a left-navigation entry, and also
|
|
62
|
+
provides a settings section and a right-sidebar tab. From top to bottom:
|
|
63
|
+
|
|
64
|
+
- **Status**: runtime directory, readiness, and one badge per component (green installed
|
|
65
|
+
by this plugin, blue external path, amber missing). Clicking a badge reinstalls the
|
|
66
|
+
component or points it at an existing directory; components installed by this plugin
|
|
67
|
+
carry `×` and can be removed individually.
|
|
68
|
+
- **Runtime** (collapsed by default): install and repair, optional model download,
|
|
69
|
+
migration, and the download sources with their measured speed (re-probe on demand).
|
|
70
|
+
- **Transcribe**: media path with a **Browse** button, then start.
|
|
71
|
+
- **Tasks**: progress bar, phase, log tail, and a **Cancel** button while running.
|
|
72
|
+
- **Projects**: pin, show hidden, delete (reference only or with the local files). Opening
|
|
73
|
+
a project shows a dialog for SRT export, `cues.json` import, cue editing and preview.
|
|
74
|
+
|
|
75
|
+
## Agent tools
|
|
76
|
+
|
|
77
|
+
| Tool | Purpose |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `subtitle_status` | runtime directory, component state, recent jobs |
|
|
80
|
+
| `subtitle_install` | install or repair the runtime (`installDir`, `withModel`) |
|
|
81
|
+
| `subtitle_transcribe` | transcribe a video or audio file into `asr.json` |
|
|
82
|
+
| `subtitle_job` | job progress and result (`waitSeconds` blocks) |
|
|
83
|
+
| `subtitle_export` | build the bilingual SRT from `asr.json` and cue files (coverage validated) |
|
|
84
|
+
|
|
85
|
+
## Data and routes
|
|
86
|
+
|
|
87
|
+
The panel reads a local JSON API under `/dsh-ai-subtitle/api/…`: `status`, `job`,
|
|
88
|
+
`job/cancel`, `projects`, `project`, `install`, `transcribe`, `pin`, `restore`, `delete`,
|
|
89
|
+
`import-cues`, `save-cues`, `export`, `fs/list`, `fs/places`, `fs/pick`, `runtime/probe`,
|
|
90
|
+
`runtime/remove`, `runtime/use-path`, `runtime/clear-path`, `runtime/migrate`, `debug`.
|
|
91
|
+
These routes listen on localhost only and bypass the DSH `/api` peer authentication, so
|
|
92
|
+
they are intended for local use.
|
|
93
|
+
|
|
94
|
+
## Runtime directory
|
|
95
|
+
|
|
96
|
+
The default is `%LOCALAPPDATA%\DshSubtitle`; another directory can be chosen at install
|
|
97
|
+
time.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
<root>/
|
|
101
|
+
bin/ ffmpeg.exe ffprobe.exe
|
|
102
|
+
python/ CPython 3.12 installed by the official installer
|
|
103
|
+
venv/ virtual environment (torch, transformers)
|
|
104
|
+
models/ Hugging Face cache (HF_HOME)
|
|
105
|
+
projects/ one directory per transcription: audio.wav, asr.json, meta.json, cues.json, subtitles.srt
|
|
106
|
+
cache/ download cache
|
|
107
|
+
logs/ client.log (panel diagnostics)
|
|
108
|
+
state.json download sources, backend, CUDA probe, path overrides, last project
|
|
109
|
+
registry.json project pin and hide state
|
|
110
|
+
runtime.json marker set by this plugin
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
All large dependencies live inside `<root>`, so deleting that directory uninstalls the
|
|
114
|
+
runtime. The plugin does not write the DSH profile and does not modify an existing Python
|
|
115
|
+
installation. A migration leaves a pointer to the new location at
|
|
116
|
+
`%LOCALAPPDATA%\DshSubtitle.location.json`.
|
|
117
|
+
|
|
118
|
+
## Command-line helpers
|
|
119
|
+
|
|
120
|
+
`scripts/` contains helpers that work outside DSH:
|
|
121
|
+
|
|
122
|
+
- `install-cli.js`: `node scripts/install-cli.js [root] [--with-model]` runs the installer;
|
|
123
|
+
- `build_srt.js`, `qa_cues.js`: export or check an SRT from `asr.json` and cue files;
|
|
124
|
+
- `split_fragments.py`: slice fragments into chunks for batch proofreading;
|
|
125
|
+
- `patch_cues.js`: deterministic edits driven by a `patch.json`, keeping project text out
|
|
126
|
+
of the code;
|
|
127
|
+
- `check-client.mjs`: checks `client.js` syntax and compares its top-level declarations
|
|
128
|
+
against a snapshot, so a removed declaration cannot silently break the panel.
|
|
129
|
+
|
|
130
|
+
## Limitations
|
|
131
|
+
|
|
132
|
+
- **Windows only**: the ffmpeg package and path handling assume Windows.
|
|
133
|
+
- **Segment timestamps**: `return_timestamps="word"` raises `IndexError` with
|
|
134
|
+
transformers 5.x and this model, so each fragment has a start and end but no per-word
|
|
135
|
+
timing.
|
|
136
|
+
- **No automatic translation or glossary**: the Chinese side is proofread by a model in
|
|
137
|
+
the session and written back to `cues.json`.
|
|
138
|
+
- The first install downloads about 3 GB (the CUDA build and the model) and needs a stable
|
|
139
|
+
network.
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
`/plugins/<package>/client.js` is served with an immutable cache whose revision comes from
|
|
144
|
+
the file mtime and size, so after editing `client.js` the plugin must be reloaded
|
|
145
|
+
(`remove_bundle` + `install_bundle`, or a DSH restart); a browser refresh alone keeps the
|
|
146
|
+
old bundle. The `ui-…` tag in the panel header shows which build is running.
|
|
147
|
+
|
|
148
|
+
The roadmap is in [docs/PLAN.md](docs/PLAN.md).
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT. Runtime components keep their own licenses: ffmpeg (npm-mirror static package or
|
|
153
|
+
gyan.dev), CPython (PSF), PyTorch (BSD-3), transformers (Apache-2.0). The default model
|
|
154
|
+
[`kotoba-tech/kotoba-whisper-v2.0`](https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0)
|
|
155
|
+
is covered by its model card.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# dsh-ai-subtitle
|
|
2
|
+
|
|
3
|
+
**日本語** · [简体中文](README.md) · [English](README.en.md) · [한국어](README.ko.md)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
|
|
10
|
+
<!-- translated-from: README.md sha256:74529e1fb540 -->
|
|
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
|
+
- **ファイル参照**:内蔵ブラウザ。クイック位置を備え、前回のディレクトリを記憶します。
|
|
29
|
+
|
|
30
|
+
未実装:用語集、自動翻訳、ASS 出力。
|
|
31
|
+
|
|
32
|
+
## 導入
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
dsh plugin --profile <profile> add dsh-ai-subtitle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
デスクトップ版では **Plugins → Add plugin** からも導入できます。プラグイン id は `dsh-ai-subtitle` です。
|
|
39
|
+
導入後、左ナビゲーションに「字幕工作台」が表示されます。
|
|
40
|
+
|
|
41
|
+
ローカルのチェックアウトから導入する場合:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
本リポジトリは DSH bundle でもあり、`package.json` の `dsh.bundle.patch` と `cordis.patch.yml`
|
|
48
|
+
で宣言しています。
|
|
49
|
+
## パネル
|
|
50
|
+
|
|
51
|
+
DSH のメインパネルと左ナビゲーションの項目として登録され、設定セクションと右サイドバーのタブも提供します。上から順に:
|
|
52
|
+
|
|
53
|
+
- **状態**:ランタイムのディレクトリ、準備状況、コンポーネントごとのバッジ(緑は本プラグインが導入、青は外部パス、黄は未導入)。バッジをクリックすると再導入または既存ディレクトリの指定ができ、本プラグインが導入したものは `×` で個別に削除できます。
|
|
54
|
+
- **ランタイム**(既定では折りたたみ):導入と修復、モデルの同時取得、全体の移行、ダウンロード元と実測速度(再測定可能)。
|
|
55
|
+
- **文字起こし**:メディアのパスと「参照」ボタン。
|
|
56
|
+
- **タスク**:進捗バー、フェーズ、ログ末尾。実行中は「キャンセル」。
|
|
57
|
+
- **プロジェクト**:ピン留め、非表示の表示、削除(参照のみ、またはローカルファイルごと)。プロジェクトを開くとダイアログで SRT 出力、`cues.json` の取り込み、キュー編集とプレビューができます。
|
|
58
|
+
|
|
59
|
+
## エージェント向けツール
|
|
60
|
+
|
|
61
|
+
| ツール | 役割 |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `subtitle_status` | ランタイムのディレクトリ、コンポーネントの状態、最近のタスク |
|
|
64
|
+
| `subtitle_install` | ランタイムの導入または修復(`installDir`、`withModel`) |
|
|
65
|
+
| `subtitle_transcribe` | 動画または音声を `asr.json` に書き出す |
|
|
66
|
+
| `subtitle_job` | タスクの進捗と結果(`waitSeconds` で待機) |
|
|
67
|
+
| `subtitle_export` | `asr.json` とキュー定義から SRT を出力(被覆を検証) |
|
|
68
|
+
|
|
69
|
+
## データと API
|
|
70
|
+
|
|
71
|
+
パネルはローカルの 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` 認証を通りません。ローカル利用を前提としています。
|
|
72
|
+
|
|
73
|
+
## ランタイムのディレクトリ
|
|
74
|
+
|
|
75
|
+
既定は `%LOCALAPPDATA%\DshSubtitle` で、導入時に別のディレクトリを指定できます。
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
<root>/
|
|
79
|
+
bin/ ffmpeg.exe ffprobe.exe
|
|
80
|
+
python/ 公式インストーラで導入した CPython 3.12
|
|
81
|
+
venv/ 仮想環境(torch、transformers)
|
|
82
|
+
models/ Hugging Face のキャッシュ(HF_HOME)
|
|
83
|
+
projects/ 文字起こしごとのディレクトリ:audio.wav、asr.json、meta.json、cues.json、subtitles.srt
|
|
84
|
+
cache/ ダウンロードのキャッシュ
|
|
85
|
+
logs/ client.log(パネルの診断ログ)
|
|
86
|
+
state.json ダウンロード元、バックエンド、CUDA の測定結果、パスの上書き、前回のプロジェクト
|
|
87
|
+
registry.json ピン留めと非表示の状態
|
|
88
|
+
runtime.json 本プラグインが導入したことを示すマーカー
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
大きな依存はすべて `<root>` 内にあり、削除すればアンインストールできます。DSH のプロファイルには書き込まず、既存の Python 環境も変更しません。移行後は新しい場所を指すポインタを `%LOCALAPPDATA%\DshSubtitle.location.json` に残します。
|
|
92
|
+
|
|
93
|
+
## コマンドラインツール
|
|
94
|
+
|
|
95
|
+
`scripts/` には DSH なしで使える補助スクリプトがあります:
|
|
96
|
+
|
|
97
|
+
- `install-cli.js`:`node scripts/install-cli.js [root] [--with-model]` でインストーラを実行;
|
|
98
|
+
- `build_srt.js`、`qa_cues.js`:`asr.json` とキュー定義から SRT を出力・検証;
|
|
99
|
+
- `split_fragments.py`:フラグメントを分割して分割校正に回す;
|
|
100
|
+
- `patch_cues.js`:`patch.json` に基づく決定的な削除・置換(プロジェクトのテキストをコードから分離);
|
|
101
|
+
- `check-client.mjs`:`client.js` の構文とトップレベル宣言のスナップショットを照合し、宣言の消失によるパネル不動作を防ぎます。
|
|
102
|
+
|
|
103
|
+
## 既知の制限
|
|
104
|
+
|
|
105
|
+
- **Windows のみ**:ffmpeg のパッケージとパス処理は Windows を前提としています。
|
|
106
|
+
- **区間単位の時刻**:transformers 5.x と kotoba-whisper の `return_timestamps="word"` は `IndexError` を送出するため、フラグメントごとの開始・終了時刻のみで、単語単位の時刻はありません。
|
|
107
|
+
- **自動翻訳・用語集なし**:中国語はセッション内のモデルが校正し、`cues.json` に書き戻します。
|
|
108
|
+
- 初回導入は約 3 GB(CUDA 版 PyTorch とモデル)で、安定した回線が必要です。
|
|
109
|
+
|
|
110
|
+
## 開発
|
|
111
|
+
|
|
112
|
+
`/plugins/<package>/client.js` は immutable キャッシュで配信され、revision はファイルの mtime とサイズから決まります。`client.js` を変更したらプラグインを再読み込み(`remove_bundle` + `install_bundle`、または DSH の再起動)してください。ページを再読み込みするだけでは古い bundle が使われます。パネル上部の `ui-…` が実行中のビルドです。
|
|
113
|
+
|
|
114
|
+
今後の予定は [docs/PLAN.md](docs/PLAN.md) にあります。
|
|
115
|
+
|
|
116
|
+
## ライセンス
|
|
117
|
+
|
|
118
|
+
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,118 @@
|
|
|
1
|
+
# dsh-ai-subtitle
|
|
2
|
+
|
|
3
|
+
**한국어** · [简体中文](README.md) · [English](README.en.md) · [日本語](README.ja.md)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
|
|
10
|
+
<!-- translated-from: README.md sha256:74529e1fb540 -->
|
|
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
|
+
- **파일 찾아보기**: 내장 브라우저로 빠른 위치를 제공하고 마지막 디렉터리를 기억합니다.
|
|
29
|
+
|
|
30
|
+
미구현: 용어집, 자동 번역, ASS 내보내기.
|
|
31
|
+
|
|
32
|
+
## 설치
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
dsh plugin --profile <profile> add dsh-ai-subtitle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
데스크톱에서는 **Plugins → Add plugin**에서도 설치할 수 있습니다. 플러그인 id는 `dsh-ai-subtitle`이며,
|
|
39
|
+
설치 후 왼쪽 내비게이션에 「字幕工作台」가 나타납니다.
|
|
40
|
+
|
|
41
|
+
로컬 체크아웃에서 설치하려면:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
이 저장소는 DSH 번들이기도 하며, `package.json`의 `dsh.bundle.patch`와 `cordis.patch.yml`로
|
|
48
|
+
선언합니다.
|
|
49
|
+
## 패널
|
|
50
|
+
|
|
51
|
+
DSH의 메인 패널과 왼쪽 내비게이션 항목으로 등록되며, 설정 섹션과 오른쪽 사이드바 탭도 제공합니다. 위에서 아래로:
|
|
52
|
+
|
|
53
|
+
- **상태**: 런타임 디렉터리, 준비 여부, 컴포넌트별 배지(초록은 이 플러그인이 설치, 파랑은 외부 경로, 노랑은 없음). 배지를 누르면 재설치하거나 기존 디렉터리를 지정할 수 있고, 이 플러그인이 설치한 것은 `×`로 개별 삭제할 수 있습니다.
|
|
54
|
+
- **런타임**(기본 접힘): 설치와 복구, 모델 동시 다운로드, 전체 이전, 다운로드 소스와 측정 속도(다시 측정 가능).
|
|
55
|
+
- **전사**: 미디어 경로와 「찾아보기」 버튼.
|
|
56
|
+
- **작업**: 진행률 표시줄, 단계, 로그 끝부분. 실행 중에는 「취소」.
|
|
57
|
+
- **프로젝트**: 고정, 숨김 표시, 삭제(참조만 또는 로컬 파일까지). 프로젝트를 열면 대화상자에서 SRT 내보내기, `cues.json` 가져오기, 큐 편집과 미리보기를 사용할 수 있습니다.
|
|
58
|
+
|
|
59
|
+
## 에이전트 도구
|
|
60
|
+
|
|
61
|
+
| 도구 | 역할 |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `subtitle_status` | 런타임 디렉터리, 컴포넌트 상태, 최근 작업 |
|
|
64
|
+
| `subtitle_install` | 런타임 설치 또는 복구(`installDir`, `withModel`) |
|
|
65
|
+
| `subtitle_transcribe` | 영상 또는 오디오를 `asr.json`으로 전사 |
|
|
66
|
+
| `subtitle_job` | 작업 진행률과 결과(`waitSeconds`로 대기) |
|
|
67
|
+
| `subtitle_export` | `asr.json`과 큐 파일로 SRT 내보내기(커버리지 검증) |
|
|
68
|
+
|
|
69
|
+
## 데이터와 API
|
|
70
|
+
|
|
71
|
+
패널은 로컬 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` 인증을 거치지 않습니다. 로컬 사용을 전제로 합니다.
|
|
72
|
+
|
|
73
|
+
## 런타임 디렉터리
|
|
74
|
+
|
|
75
|
+
기본값은 `%LOCALAPPDATA%\DshSubtitle`이며 설치할 때 다른 디렉터리를 지정할 수 있습니다.
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
<root>/
|
|
79
|
+
bin/ ffmpeg.exe ffprobe.exe
|
|
80
|
+
python/ 공식 설치 프로그램으로 설치한 CPython 3.12
|
|
81
|
+
venv/ 가상 환경(torch, transformers)
|
|
82
|
+
models/ Hugging Face 캐시(HF_HOME)
|
|
83
|
+
projects/ 전사마다 하나의 디렉터리: audio.wav, asr.json, meta.json, cues.json, subtitles.srt
|
|
84
|
+
cache/ 다운로드 캐시
|
|
85
|
+
logs/ client.log(패널 진단 로그)
|
|
86
|
+
state.json 다운로드 소스, 백엔드, CUDA 측정 결과, 경로 재정의, 마지막 프로젝트
|
|
87
|
+
registry.json 고정과 숨김 상태
|
|
88
|
+
runtime.json 이 플러그인이 설치했다는 표식
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
큰 의존성은 모두 `<root>` 안에 있어 그 디렉터리를 삭제하면 완전히 제거됩니다. DSH 프로필에 쓰지 않고 기존 Python 환경도 변경하지 않습니다. 이전 후에는 새 위치를 가리키는 포인터를 `%LOCALAPPDATA%\DshSubtitle.location.json`에 남깁니다.
|
|
92
|
+
|
|
93
|
+
## 명령줄 도구
|
|
94
|
+
|
|
95
|
+
`scripts/`에는 DSH 없이 사용할 수 있는 보조 스크립트가 있습니다:
|
|
96
|
+
|
|
97
|
+
- `install-cli.js`: `node scripts/install-cli.js [root] [--with-model]`로 설치 프로그램을 실행;
|
|
98
|
+
- `build_srt.js`, `qa_cues.js`: `asr.json`과 큐 파일로 SRT를 내보내거나 검증;
|
|
99
|
+
- `split_fragments.py`: 프래그먼트를 여러 조각으로 나눠 배치 교정에 사용;
|
|
100
|
+
- `patch_cues.js`: `patch.json`에 따른 결정적 삭제·치환(프로젝트 텍스트를 코드와 분리);
|
|
101
|
+
- `check-client.mjs`: `client.js` 구문과 최상위 선언 스냅숏을 대조해 선언 누락으로 패널이 렌더링되지 않는 일을 방지합니다.
|
|
102
|
+
|
|
103
|
+
## 알려진 제한
|
|
104
|
+
|
|
105
|
+
- **Windows 전용**: ffmpeg 패키지와 경로 처리가 Windows를 전제로 합니다.
|
|
106
|
+
- **구간 단위 시각**: transformers 5.x와 kotoba-whisper의 `return_timestamps="word"`는 `IndexError`를 발생시키므로 프래그먼트마다 시작·종료 시각만 있고 단어 단위 시각은 없습니다.
|
|
107
|
+
- **자동 번역과 용어집 없음**: 중국어는 세션의 모델이 교정해 `cues.json`에 기록합니다.
|
|
108
|
+
- 첫 설치에 약 3 GB(CUDA 빌드와 모델)를 내려받으며 안정적인 회선이 필요합니다.
|
|
109
|
+
|
|
110
|
+
## 개발
|
|
111
|
+
|
|
112
|
+
`/plugins/<package>/client.js`는 immutable 캐시로 제공되며 revision은 파일 mtime과 크기에서 결정됩니다. `client.js`를 수정한 뒤에는 플러그인을 다시 로드(`remove_bundle` + `install_bundle`, 또는 DSH 재시작)해야 합니다. 페이지를 새로 고치는 것만으로는 이전 번들이 계속 사용됩니다. 패널 상단의 `ui-…` 표식이 현재 빌드입니다.
|
|
113
|
+
|
|
114
|
+
앞으로의 계획은 [docs/PLAN.md](docs/PLAN.md)에 있습니다.
|
|
115
|
+
|
|
116
|
+
## 라이선스
|
|
117
|
+
|
|
118
|
+
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,114 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-ai-subtitle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**简体中文** · [English](README.en.md) · [日本語](README.ja.md) · [한국어](README.ko.md)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yanxijian/dsh-ai-subtitle/actions/workflows/hygiene.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
|
+
[](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
|
+
- **文件浏览**:内置文件浏览器,提供快捷位置并记住上次访问的目录。
|
|
27
|
+
|
|
28
|
+
尚未实现:术语表、自动翻译、ASS 导出。
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
dsh plugin --profile <profile> add dsh-ai-subtitle
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
桌面用户也可以在 **Plugins → Add plugin** 中安装。插件 id 为 `dsh-ai-subtitle`,安装后左侧导航出现「字幕工作台」。
|
|
37
|
+
|
|
38
|
+
从本地检出安装:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
dsh plugin --profile <profile> add link:/path/to/dsh-ai-subtitle
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
本仓库同时是 DSH bundle,由 `package.json` 的 `dsh.bundle.patch` 与 `cordis.patch.yml` 声明。
|
|
45
|
+
## 界面
|
|
46
|
+
|
|
47
|
+
面板注册为 DSH 主面板与左侧导航入口,同时提供设置分区和右侧栏标签。自上而下:
|
|
48
|
+
|
|
49
|
+
- **状态**:运行时目录、是否就绪、各组件徽章(绿色为本插件安装、蓝色为外部路径、黄色为缺失)。点击徽章可重新安装或指定已有目录;本插件安装的组件带 `×`,可单独删除。
|
|
50
|
+
- **运行时**(默认折叠):安装与修复、是否同时下载模型、整体迁移、下载源及其测得速率(可重新测速)。
|
|
51
|
+
- **转写**:媒体路径与「浏览」按钮,随后开始转写。
|
|
52
|
+
- **任务**:进度条、阶段、日志尾部;运行中的任务右侧有「取消」。
|
|
53
|
+
- **项目**:置顶、显示已隐藏、删除(仅移除引用或连本地文件一起删除);打开项目后可在弹窗中导出 SRT、导入外部 `cues.json`、编辑 cue 并预览。
|
|
54
|
+
|
|
55
|
+
## Agent 工具
|
|
56
|
+
|
|
57
|
+
| 工具 | 作用 |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `subtitle_status` | 运行时目录、各组件状态、最近任务 |
|
|
60
|
+
| `subtitle_install` | 安装或修复运行时(`installDir`、`withModel`) |
|
|
61
|
+
| `subtitle_transcribe` | 转写视频或音频,产出 `asr.json` |
|
|
62
|
+
| `subtitle_job` | 查询任务进度与结果(`waitSeconds` 可阻塞等待) |
|
|
63
|
+
| `subtitle_export` | 由 `asr.json` 与 cue 文件导出双语 SRT(校验覆盖率) |
|
|
64
|
+
|
|
65
|
+
## 数据与接口
|
|
66
|
+
|
|
67
|
+
面板通过本地 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` 鉴权,适用于本机使用。
|
|
68
|
+
|
|
69
|
+
## 运行时目录
|
|
70
|
+
|
|
71
|
+
默认 `%LOCALAPPDATA%\DshSubtitle`,安装时可指定其他目录。
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
<root>/
|
|
75
|
+
bin/ ffmpeg.exe ffprobe.exe
|
|
76
|
+
python/ 官方安装器安装的 CPython 3.12
|
|
77
|
+
venv/ 虚拟环境(torch、transformers)
|
|
78
|
+
models/ Hugging Face 模型缓存(HF_HOME)
|
|
79
|
+
projects/ 每次转写一个目录:audio.wav、asr.json、meta.json、cues.json、subtitles.srt
|
|
80
|
+
cache/ 下载缓存
|
|
81
|
+
logs/ client.log(面板诊断日志)
|
|
82
|
+
state.json 下载源、后端、CUDA 探测结果、路径覆盖、上次项目
|
|
83
|
+
registry.json 项目置顶与隐藏状态
|
|
84
|
+
runtime.json 本插件安装标记
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
所有大体积依赖都位于 `<root>` 内,删除该目录即可完全卸载。插件不写入 DSH profile,也不修改用户已有的 Python 环境。迁移后会在 `%LOCALAPPDATA%\DshSubtitle.location.json` 留下指向新位置的指针。
|
|
88
|
+
|
|
89
|
+
## 命令行工具
|
|
90
|
+
|
|
91
|
+
`scripts/` 下提供可脱离 DSH 使用的辅助脚本:
|
|
92
|
+
|
|
93
|
+
- `install-cli.js`:`node scripts/install-cli.js [root] [--with-model]`,直接运行安装器;
|
|
94
|
+
- `build_srt.js`、`qa_cues.js`:由 `asr.json` 与 cue 文件导出或校验 SRT;
|
|
95
|
+
- `split_fragments.py`:把碎片切成若干块,便于分批校对;
|
|
96
|
+
- `patch_cues.js`:按 `patch.json` 做确定性删改,使项目文本与代码分离;
|
|
97
|
+
- `check-client.mjs`:检查 `client.js` 语法并核对顶层声明快照,防止误删声明导致面板无法渲染。
|
|
98
|
+
|
|
99
|
+
## 已知限制
|
|
100
|
+
|
|
101
|
+
- **仅 Windows**:ffmpeg 静态包与路径处理按 Windows 实现。
|
|
102
|
+
- **段级时间戳**:transformers 5.x 与 kotoba-whisper 的 `return_timestamps="word"` 会抛出 `IndexError`,因此每条碎片只有起止时间,没有逐词时间。
|
|
103
|
+
- **无自动翻译与术语表**:中文由会话中的模型校对后写回 `cues.json`。
|
|
104
|
+
- 首次安装约 3 GB(CUDA 版 PyTorch 与模型),需要稳定网络。
|
|
105
|
+
|
|
106
|
+
## 开发
|
|
107
|
+
|
|
108
|
+
`/plugins/<package>/client.js` 以 immutable 缓存提供,revision 取自文件 mtime 与大小,因此修改 `client.js` 后必须重新加载插件(`remove_bundle` + `install_bundle`,或重启 DSH);仅刷新页面会继续使用旧 bundle。面板标题中的 `ui-…` 标记可用于确认当前运行的版本。
|
|
109
|
+
|
|
110
|
+
后续计划见 [docs/PLAN.md](docs/PLAN.md)。
|
|
111
|
+
|
|
112
|
+
## 许可
|
|
113
|
+
|
|
114
|
+
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) 以模型卡为准。
|