dsh-ai-subtitle 0.3.3 → 0.4.1
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/README.en.md +6 -1
- package/README.ja.md +3 -1
- package/README.ko.md +3 -1
- package/README.md +7 -2
- package/client.js +323 -22
- package/docs/REVIEW.md +4 -4
- package/index.js +54 -3
- package/package.json +1 -1
- package/python/worker.py +86 -5
- package/src/api.js +148 -4
- package/src/audio.js +20 -0
- package/src/cues.js +222 -9
- package/src/export-name.js +22 -0
- package/src/glossary.js +21 -1
- package/src/library.js +98 -0
- package/src/llm.js +209 -32
- package/src/quality.js +61 -0
- package/src/resplit.js +143 -0
- package/src/review.js +9 -5
package/README.en.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
8
|
[](https://nodejs.org/)
|
|
9
9
|
|
|
10
|
-
<!-- translated-from: README.md sha256:
|
|
10
|
+
<!-- translated-from: README.md sha256:24b126ef81da -->
|
|
11
11
|
|
|
12
12
|
A subtitle plugin for DeepSeek Harness (DSH) that turns Japanese video into bilingual
|
|
13
13
|
Japanese/Chinese SRT files. The plugin installs every runtime component it needs
|
|
@@ -45,6 +45,11 @@ video/audio ──ffmpeg──▶ 16 kHz wav ──energy VAD + Whisper──▶
|
|
|
45
45
|
- **Recent files**: the media picker expands into recent files and folders.
|
|
46
46
|
- **Line deletion**: deleting a cue marks it as skipped, so coverage and export stay valid.
|
|
47
47
|
- **File browser**: in-app picker with quick locations that remembers the last directory.
|
|
48
|
+
- **Cross-project glossary**: names, terms and background presets live in a shared library and merge into every project; project entries win.
|
|
49
|
+
- **Quality report**: lists empty, too short or too long lines, kana inside Chinese, odd length ratios and near-simultaneous duplicates.
|
|
50
|
+
- **Tidy and smart split**: "Tidy" merges short lines and splits long ones; "Smart split" asks the model to re-segment by meaning and speaker turns.
|
|
51
|
+
- **Export next to the video**: same name as the video; an existing subtitle is renamed to `(1)`, `(2)` first.
|
|
52
|
+
- **Save disk space**: delete the project's `audio.wav` after transcription; transcript and subtitles stay.
|
|
48
53
|
|
|
49
54
|
Not implemented yet: ASS export with styling.
|
|
50
55
|
|
package/README.ja.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
8
|
[](https://nodejs.org/)
|
|
9
9
|
|
|
10
|
-
<!-- translated-from: README.md sha256:
|
|
10
|
+
<!-- translated-from: README.md sha256:24b126ef81da -->
|
|
11
11
|
|
|
12
12
|
DeepSeek Harness(DSH)の字幕プラグインです。日本語動画を日中バイリンガルの SRT に変換します。必要なランタイム(ffmpeg、CPython、PyTorch、transformers)は指定ディレクトリにすべて導入されるため、Python・ffmpeg・モデルを事前に用意する必要はありません。
|
|
13
13
|
|
|
@@ -37,6 +37,8 @@ DeepSeek Harness(DSH)の字幕プラグインです。日本語動画を日
|
|
|
37
37
|
|
|
38
38
|
## 使い方
|
|
39
39
|
|
|
40
|
+
共通の用語集(人名・用語・背景テンプレート)はプロジェクトをまたいで共有され、翻訳時に自動で統合されます。品質レポートは空欄・短すぎる行・長すぎる行・かなの混入・長さの比率・ほぼ同時の重複を一覧します。「整理」は短い行をまとめ、長い行を分け、「スマート分割」は意味と話者の切り替わりで再分割します。字幕は動画と同じフォルダに同じ名前で書き出せ(既存は `(1)`、`(2)` に改名)、文字起こし後の `audio.wav` は削除して容量を空けられます。
|
|
41
|
+
|
|
40
42
|
パネル下部の「使用説明」から同じ流れを開けます。初回は次の順番で:
|
|
41
43
|
|
|
42
44
|
1. **ランタイムをインストール**(一度だけ):ffmpeg、Python、PyTorch を約 3 GB ダウンロード。NVIDIA GPU があれば CUDA、なければ CPU。Whisper モデル(約 1.6 GB)を同時に落とすこともできます。
|
package/README.ko.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-ai-subtitle)
|
|
8
8
|
[](https://nodejs.org/)
|
|
9
9
|
|
|
10
|
-
<!-- translated-from: README.md sha256:
|
|
10
|
+
<!-- translated-from: README.md sha256:24b126ef81da -->
|
|
11
11
|
|
|
12
12
|
DeepSeek Harness(DSH)용 자막 플러그인으로, 일본어 영상을 일중 이중 언어 SRT로 변환합니다. 필요한 런타임(ffmpeg, CPython, PyTorch, transformers)은 지정한 디렉터리에 모두 설치되므로 Python, ffmpeg, 모델을 미리 준비할 필요가 없습니다.
|
|
13
13
|
|
|
@@ -37,6 +37,8 @@ DeepSeek Harness(DSH)용 자막 플러그인으로, 일본어 영상을 일중
|
|
|
37
37
|
|
|
38
38
|
## 사용 방법
|
|
39
39
|
|
|
40
|
+
용어집(인명·용어·배경 템플릿)은 프로젝트 간 공유되며 번역할 때 자동으로 합쳐집니다. 품질 보고서는 빈 줄, 너무 짧거나 긴 줄, 가나 혼입, 길이 비율, 거의 동시에 중복된 줄을 모아 보여 줍니다. "정리"는 짧은 줄을 합치고 긴 줄을 나누며, "스마트 분할"은 의미와 화자 전환에 따라 다시 나눕니다. 자막은 영상과 같은 폴더에 같은 이름으로 내보낼 수 있고(기존 파일은 `(1)`, `(2)`로 이름 변경), 전사 후 `audio.wav`를 삭제해 공간을 절약할 수 있습니다.
|
|
41
|
+
|
|
40
42
|
패널 하단의 「사용 설명」에서 같은 안내를 열 수 있습니다. 처음 사용하는 순서:
|
|
41
43
|
|
|
42
44
|
1. **런타임 설치**(한 번만): ffmpeg, Python, PyTorch 약 3 GB를 내려받습니다. NVIDIA GPU가 있으면 CUDA, 없으면 CPU. Whisper 모델(약 1.6 GB)을 함께 받을 수도 있습니다.
|
package/README.md
CHANGED
|
@@ -30,6 +30,11 @@ DeepSeek Harness(DSH)的字幕插件,把日语视频转成中日双语 SRT
|
|
|
30
30
|
- **最近使用**:浏览媒体时可展开最近用过的文件与文件夹。
|
|
31
31
|
- **逐条删除**:不需要的行直接删除(内部记为跳过段),不影响覆盖率与导出。
|
|
32
32
|
- **文件浏览**:内置文件浏览器,提供快捷位置并记住上次访问的目录。
|
|
33
|
+
- **跨项目术语库**:常用人名、术语和背景模板存成一份共享库,翻译时自动并入;项目里的条目优先。
|
|
34
|
+
- **质量报告**:一次扫出空中文、过短/过长、假名混入、比例异常和几乎同时重复的条目。
|
|
35
|
+
- **整理与智能拆分**:「整理字幕」合并过短句、拆开过长句;「智能拆分」让模型按语义和说话人转折重新分段。
|
|
36
|
+
- **导出到视频目录**:与视频同名,已存在时按 Windows 方式改名为 `(1)`、`(2)`。
|
|
37
|
+
- **节省空间**:转写后可删除项目里的 `audio.wav`,识别结果和字幕保留。
|
|
33
38
|
|
|
34
39
|
尚未实现:ASS 导出(带样式的字幕)。
|
|
35
40
|
|
|
@@ -39,9 +44,9 @@ DeepSeek Harness(DSH)的字幕插件,把日语视频转成中日双语 SRT
|
|
|
39
44
|
|
|
40
45
|
1. **安装运行时**(只做一次):点「安装运行时」,下载 ffmpeg、Python、PyTorch(约 3 GB)。有 NVIDIA 显卡自动用 CUDA,没有则用 CPU;可以勾选同时下载 Whisper 模型(约 1.6 GB)。
|
|
41
46
|
2. **转写**:选择视频或音频,点开始。任务卡显示进度、可取消;完成后项目进入列表。
|
|
42
|
-
3. **翻译**:打开项目 → 选模型 →
|
|
47
|
+
3. **翻译**:打开项目 → 选模型 → 「自动翻译本批」或「自动翻译全部剩余」。想同时修正识别错误,勾选「同时校正日文识别」;「并发翻译」默认关闭,需要更快时可以打开。
|
|
43
48
|
4. **校对与修改**:「逐条修改」可改日文/中文、拆分合并、按 0.1 秒微调时间、删除不需要的行;给某条或整批写意见后「保存意见并重译本批」。
|
|
44
|
-
5.
|
|
49
|
+
5. **导出**:点「导出字幕」得到项目目录里的 `.srt`;点「导出到视频目录」会写一份与视频同名的字幕,播放器可直接加载。
|
|
45
50
|
|
|
46
51
|
「背景与术语」里的标签和说明会随每次翻译交给模型,适合写人名、作品名和节目风格;术语表支持粘贴 CSV 导入,也可以导出。
|
|
47
52
|
|
package/client.js
CHANGED
|
@@ -10,7 +10,7 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
const PANEL_ID = 'subtitle-studio-panel'
|
|
11
11
|
const API = '/dsh-ai-subtitle/api'
|
|
12
12
|
// Bump whenever the bundle needs to be distinguishable in the running page.
|
|
13
|
-
const BUILD = 'ui-2026-12-
|
|
13
|
+
const BUILD = 'ui-2026-12-06e'
|
|
14
14
|
function trace(message) {
|
|
15
15
|
try {
|
|
16
16
|
const payload = JSON.stringify({ msg: String(message).slice(0, 300) })
|
|
@@ -25,6 +25,8 @@ window.__ModuleLoader__.load({
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const shortPath = (value) => String(value || "").split(/[\\/]/).filter(Boolean).pop() || String(value || "")
|
|
29
|
+
|
|
28
30
|
const MOUNT_GUARD = { start: 0, count: 0 }
|
|
29
31
|
/** Stop rendering when the panel is remounted in a loop, which freezes the page. */
|
|
30
32
|
function mountAllowed() {
|
|
@@ -454,7 +456,12 @@ window.__ModuleLoader__.load({
|
|
|
454
456
|
const [contextDialog, setContextDialog] = useState(false)
|
|
455
457
|
const [glossaryInfo, setGlossaryInfo] = useState(null)
|
|
456
458
|
const [glossaryText, setGlossaryText] = useState('')
|
|
459
|
+
const [library, setLibrary] = useState({ terms: [], hints: [] })
|
|
460
|
+
const [libJp, setLibJp] = useState('')
|
|
461
|
+
const [libZh, setLibZh] = useState('')
|
|
462
|
+
const [hintName, setHintName] = useState('')
|
|
457
463
|
const [proofread, setProofread] = useState(true)
|
|
464
|
+
const [fastTranslate, setFastTranslate] = useState(false)
|
|
458
465
|
const [feedbackDraft, setFeedbackDraft] = useState({})
|
|
459
466
|
const [batchNote, setBatchNote] = useState('')
|
|
460
467
|
const [reviewBatch, setReviewBatch] = useState(null)
|
|
@@ -472,6 +479,10 @@ window.__ModuleLoader__.load({
|
|
|
472
479
|
const [projectsInfo, setProjectsInfo] = useState(null)
|
|
473
480
|
const [projectsDialog, setProjectsDialog] = useState(false)
|
|
474
481
|
const [helpDialog, setHelpDialog] = useState(false)
|
|
482
|
+
const [mergeDialog, setMergeDialog] = useState(false)
|
|
483
|
+
const [qualityOpen, setQualityOpen] = useState(false)
|
|
484
|
+
const [quality, setQuality] = useState(null)
|
|
485
|
+
const [audioDialog, setAudioDialog] = useState(false)
|
|
475
486
|
const [projectsDraft, setProjectsDraft] = useState('')
|
|
476
487
|
const [projectsMove, setProjectsMove] = useState(true)
|
|
477
488
|
const [places, setPlaces] = useState([])
|
|
@@ -586,6 +597,128 @@ window.__ModuleLoader__.load({
|
|
|
586
597
|
if (result.error) setNotice('打开失败:' + result.error)
|
|
587
598
|
}
|
|
588
599
|
|
|
600
|
+
const tidySubtitles = async () => {
|
|
601
|
+
if (!detail) return
|
|
602
|
+
const merged = await callApi('/review/merge', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
603
|
+
if (merged.error) {
|
|
604
|
+
setMergeDialog(false)
|
|
605
|
+
setNotice('整理失败(合并):' + merged.error)
|
|
606
|
+
return
|
|
607
|
+
}
|
|
608
|
+
const split = await callApi('/review/split', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
609
|
+
setMergeDialog(false)
|
|
610
|
+
if (split.error) {
|
|
611
|
+
setNotice('整理失败(拆分):' + split.error)
|
|
612
|
+
return
|
|
613
|
+
}
|
|
614
|
+
setNotice(
|
|
615
|
+
'整理完成:合并 ' + merged.merged + ' 处、拆分 ' + split.split + ' 处,' + merged.before + ' 条 → ' + split.after + ' 条',
|
|
616
|
+
)
|
|
617
|
+
await openProject(detail)
|
|
618
|
+
refresh()
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const removeAudio = async () => {
|
|
622
|
+
if (!detail) return
|
|
623
|
+
const result = await callApi('/project/audio', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
624
|
+
setAudioDialog(false)
|
|
625
|
+
if (result.error) {
|
|
626
|
+
setNotice('删除音频失败:' + result.error)
|
|
627
|
+
return
|
|
628
|
+
}
|
|
629
|
+
setNotice('已删除音频,释放 ' + Math.round(result.freed / 1024 / 1024) + ' MB')
|
|
630
|
+
refresh()
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const openQuality = async () => {
|
|
634
|
+
if (!detail) return
|
|
635
|
+
const result = await callApi('/quality?dir=' + encodeURIComponent(detail.dir))
|
|
636
|
+
if (result.error) {
|
|
637
|
+
setNotice('质量报告:' + result.error)
|
|
638
|
+
return
|
|
639
|
+
}
|
|
640
|
+
setQuality(result)
|
|
641
|
+
setQualityOpen(true)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
const resplitNow = async () => {
|
|
645
|
+
if (!detail) return
|
|
646
|
+
setTranslateBusy(true)
|
|
647
|
+
setTranslateError('')
|
|
648
|
+
const result = await callApi('/review/resplit', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
649
|
+
if (result.error) {
|
|
650
|
+
setTranslateBusy(false)
|
|
651
|
+
setTranslateError(result.error)
|
|
652
|
+
return
|
|
653
|
+
}
|
|
654
|
+
setNotice('智能拆分已开始')
|
|
655
|
+
for (let tick = 0; tick < 900; tick += 1) {
|
|
656
|
+
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
657
|
+
const job = await callApi('/job?id=' + encodeURIComponent(result.jobId))
|
|
658
|
+
if (job.error) {
|
|
659
|
+
setNotice('智能拆分:' + job.error)
|
|
660
|
+
break
|
|
661
|
+
}
|
|
662
|
+
if (job.status === 'done') {
|
|
663
|
+
setNotice('智能拆分完成')
|
|
664
|
+
break
|
|
665
|
+
}
|
|
666
|
+
if (job.status === 'failed') {
|
|
667
|
+
setTranslateError(job.error || '未知错误')
|
|
668
|
+
setNotice('智能拆分失败')
|
|
669
|
+
break
|
|
670
|
+
}
|
|
671
|
+
if (job.status === 'cancelled') {
|
|
672
|
+
setNotice('智能拆分已取消')
|
|
673
|
+
break
|
|
674
|
+
}
|
|
675
|
+
setNotice('智能拆分中:' + (job.msg || job.pct + '%'))
|
|
676
|
+
}
|
|
677
|
+
setTranslateBusy(false)
|
|
678
|
+
await openProject(detail)
|
|
679
|
+
refresh()
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
const libraryAction = async (payload) => {
|
|
683
|
+
const result = await callApi('/library', { method: 'POST', body: JSON.stringify({ dir: detail.dir, ...payload }) })
|
|
684
|
+
if (result.error) {
|
|
685
|
+
setNotice('常用术语:' + result.error)
|
|
686
|
+
return false
|
|
687
|
+
}
|
|
688
|
+
if (result.library) setLibrary(result.library)
|
|
689
|
+
return true
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
const addLibraryTerm = async () => {
|
|
693
|
+
if (!libJp.trim() || !libZh.trim()) return
|
|
694
|
+
if (await libraryAction({ action: 'add-term', jp: libJp.trim(), zh: libZh.trim() })) {
|
|
695
|
+
setLibJp('')
|
|
696
|
+
setLibZh('')
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const absorbTerms = async () => {
|
|
701
|
+
if (await libraryAction({ action: 'absorb-project' })) setNotice('已把本项目术语保存到常用术语')
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const applyHintPreset = async (name) => {
|
|
705
|
+
if (await libraryAction({ action: 'apply-hint', name })) {
|
|
706
|
+
setNotice('已套用背景模板:' + name)
|
|
707
|
+
await loadHints(detail.dir)
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
const saveCurrentHint = async () => {
|
|
712
|
+
const name = hintName.trim() || (hintsInfo && hintsInfo.tags.length ? hintsInfo.tags[0] : '')
|
|
713
|
+
if (!name) {
|
|
714
|
+
setNotice('先给背景模板起个名字')
|
|
715
|
+
return
|
|
716
|
+
}
|
|
717
|
+
if (await libraryAction({ action: 'save-hint', name, tags: hintsInfo ? hintsInfo.tags : [], note: hintsInfo ? hintsInfo.note : '' })) {
|
|
718
|
+
setNotice('已保存背景模板:' + name)
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
589
722
|
const loadProjectsInfo = async () => {
|
|
590
723
|
const info = await callApi('/settings')
|
|
591
724
|
if (!info.error) setProjectsInfo(info)
|
|
@@ -802,13 +935,15 @@ window.__ModuleLoader__.load({
|
|
|
802
935
|
return h('span', null, '翻译 ' + progress.translated + '/' + progress.batches + ' 批')
|
|
803
936
|
}
|
|
804
937
|
|
|
805
|
-
const exportProject = async (dir) => {
|
|
806
|
-
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir }) })
|
|
938
|
+
const exportProject = async (dir, location) => {
|
|
939
|
+
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir, location }) })
|
|
807
940
|
if (result.error) {
|
|
808
941
|
setNotice('导出失败:' + result.error)
|
|
809
942
|
return
|
|
810
943
|
}
|
|
811
|
-
|
|
944
|
+
const renamed = result.backup ? ';旧字幕改名为 ' + shortPath(result.backup) : ''
|
|
945
|
+
const where = location === 'video' ? '视频目录' : '项目目录'
|
|
946
|
+
setNotice('已导出 ' + result.stats.cues + ' 条字幕到' + where + ':' + shortPath(result.out) + renamed)
|
|
812
947
|
refresh()
|
|
813
948
|
}
|
|
814
949
|
|
|
@@ -832,7 +967,7 @@ window.__ModuleLoader__.load({
|
|
|
832
967
|
setTranslateNotice('翻译中…')
|
|
833
968
|
setTranslateError('')
|
|
834
969
|
try {
|
|
835
|
-
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate' }
|
|
970
|
+
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate', concurrency: fastTranslate ? 3 : 1 }
|
|
836
971
|
if (all) payload.all = true
|
|
837
972
|
else if (reviewBatch) payload.batch = reviewBatch.batch
|
|
838
973
|
if (llmRoute && llmRoute.active) {
|
|
@@ -850,6 +985,7 @@ window.__ModuleLoader__.load({
|
|
|
850
985
|
setNotice('开始翻译:共 ' + result.total + ' 批')
|
|
851
986
|
setTranslateNotice('准备中…')
|
|
852
987
|
const dir = detail.dir
|
|
988
|
+
let jobError = ''
|
|
853
989
|
for (let tick = 0; tick < 900; tick += 1) {
|
|
854
990
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
855
991
|
const job = await callApi('/job?id=' + encodeURIComponent(result.jobId))
|
|
@@ -863,7 +999,7 @@ window.__ModuleLoader__.load({
|
|
|
863
999
|
}
|
|
864
1000
|
if (job.status === 'failed') {
|
|
865
1001
|
setNotice('翻译失败:' + (job.error || '未知错误'))
|
|
866
|
-
|
|
1002
|
+
jobError = job.error || '未知错误'
|
|
867
1003
|
break
|
|
868
1004
|
}
|
|
869
1005
|
if (job.status === 'cancelled') {
|
|
@@ -874,7 +1010,8 @@ window.__ModuleLoader__.load({
|
|
|
874
1010
|
setTranslateNotice(job.msg || '翻译中…')
|
|
875
1011
|
}
|
|
876
1012
|
setTranslateJobId('')
|
|
877
|
-
await
|
|
1013
|
+
await openProject(detail)
|
|
1014
|
+
if (jobError) setTranslateError(jobError)
|
|
878
1015
|
refresh()
|
|
879
1016
|
return
|
|
880
1017
|
}
|
|
@@ -911,6 +1048,8 @@ window.__ModuleLoader__.load({
|
|
|
911
1048
|
const loadGlossaryInfo = async (dir) => {
|
|
912
1049
|
const result = await callApi('/glossary?dir=' + encodeURIComponent(dir))
|
|
913
1050
|
if (!result.error) setGlossaryInfo(result.glossary)
|
|
1051
|
+
const lib = await callApi('/library?dir=' + encodeURIComponent(dir))
|
|
1052
|
+
if (!lib.error) setLibrary(lib.library)
|
|
914
1053
|
}
|
|
915
1054
|
|
|
916
1055
|
const openContextDialog = async () => {
|
|
@@ -1107,14 +1246,16 @@ window.__ModuleLoader__.load({
|
|
|
1107
1246
|
openProject(detail)
|
|
1108
1247
|
}
|
|
1109
1248
|
|
|
1110
|
-
const exportSrt = async () => {
|
|
1249
|
+
const exportSrt = async (location) => {
|
|
1111
1250
|
if (!detail) return
|
|
1112
|
-
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
1251
|
+
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir: detail.dir, location }) })
|
|
1113
1252
|
if (result.error) {
|
|
1114
1253
|
setNotice('导出失败:' + result.error + (result.details ? '(' + result.details.join('; ') + ')' : ''))
|
|
1115
1254
|
return
|
|
1116
1255
|
}
|
|
1117
|
-
|
|
1256
|
+
const renamed = result.backup ? ';旧字幕改名为 ' + shortPath(result.backup) : ''
|
|
1257
|
+
const where = location === 'video' ? '视频目录' : '项目目录'
|
|
1258
|
+
setNotice('已导出 ' + result.stats.cues + ' 条字幕到' + where + ':' + shortPath(result.out) + renamed)
|
|
1118
1259
|
openProject(detail)
|
|
1119
1260
|
refresh()
|
|
1120
1261
|
}
|
|
@@ -1342,7 +1483,7 @@ window.__ModuleLoader__.load({
|
|
|
1342
1483
|
h('input', {
|
|
1343
1484
|
style: { ...input, marginTop: 6 },
|
|
1344
1485
|
value: migrateTarget,
|
|
1345
|
-
placeholder: '目标目录,例如
|
|
1486
|
+
placeholder: '目标目录,例如 %LOCALAPPDATA%\\DshSubtitle',
|
|
1346
1487
|
onChange: (event) => setMigrateTarget(event.target.value),
|
|
1347
1488
|
}),
|
|
1348
1489
|
h(B, { style: { ...button, marginTop: 6 }, onClick: migrate }, '一键迁移'),
|
|
@@ -1361,7 +1502,7 @@ window.__ModuleLoader__.load({
|
|
|
1361
1502
|
h('input', {
|
|
1362
1503
|
style: input,
|
|
1363
1504
|
value: media,
|
|
1364
|
-
placeholder: '视频或音频的绝对路径,例如
|
|
1505
|
+
placeholder: '视频或音频的绝对路径,例如 %USERPROFILE%\\Videos\\foo.mp4',
|
|
1365
1506
|
onChange: (event) => setMedia(event.target.value),
|
|
1366
1507
|
}),
|
|
1367
1508
|
h(
|
|
@@ -1454,7 +1595,7 @@ window.__ModuleLoader__.load({
|
|
|
1454
1595
|
? h('div', { style: code }, '还没有项目,先在下面转写一个视频')
|
|
1455
1596
|
: h(
|
|
1456
1597
|
'div',
|
|
1457
|
-
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
1598
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 'min(50vh, 480px)', overflowY: 'auto', paddingRight: 6, scrollbarWidth: 'thin' } },
|
|
1458
1599
|
visibleProjects.map((project) =>
|
|
1459
1600
|
h(
|
|
1460
1601
|
'div',
|
|
@@ -1474,10 +1615,20 @@ window.__ModuleLoader__.load({
|
|
|
1474
1615
|
style: { ...primary, padding: '4px 10px', flex: '0 0 auto' },
|
|
1475
1616
|
onClick: () => openProject(project),
|
|
1476
1617
|
}, project.review.translated === 0 ? '开始翻译' : '继续翻译')
|
|
1477
|
-
:
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1618
|
+
: [
|
|
1619
|
+
h(B, {
|
|
1620
|
+
key: 'export-project',
|
|
1621
|
+
style: { ...medium, flex: '0 0 auto' },
|
|
1622
|
+
title: '导出到项目目录',
|
|
1623
|
+
onClick: () => exportProject(project.dir),
|
|
1624
|
+
}, '导出到项目'),
|
|
1625
|
+
h(B, {
|
|
1626
|
+
key: 'export-video',
|
|
1627
|
+
style: { ...medium, flex: '0 0 auto' },
|
|
1628
|
+
title: '导出到视频目录,文件名与视频一致',
|
|
1629
|
+
onClick: () => exportProject(project.dir, 'video'),
|
|
1630
|
+
}, '导出到视频'),
|
|
1631
|
+
],
|
|
1481
1632
|
h(B, {
|
|
1482
1633
|
style: { ...button, padding: '6px 8px' },
|
|
1483
1634
|
title: project.pinned ? '取消置顶' : '置顶',
|
|
@@ -1546,7 +1697,8 @@ window.__ModuleLoader__.load({
|
|
|
1546
1697
|
h(
|
|
1547
1698
|
'div',
|
|
1548
1699
|
{ key: 'toolbar', style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1549
|
-
h(B, { style: primary, onClick: exportSrt }, '导出字幕'),
|
|
1700
|
+
h(B, { style: primary, onClick: () => exportSrt() }, '导出字幕'),
|
|
1701
|
+
h(B, { style: button, onClick: () => exportSrt('video') }, '导出到视频目录'),
|
|
1550
1702
|
h(B,
|
|
1551
1703
|
{
|
|
1552
1704
|
style: editing ? primary : button,
|
|
@@ -1562,6 +1714,10 @@ window.__ModuleLoader__.load({
|
|
|
1562
1714
|
? h(B, { style: primary, onClick: saveEdits }, '保存修改')
|
|
1563
1715
|
: h(B, { style: button, onClick: () => openProject(detail) }, '刷新'),
|
|
1564
1716
|
editing ? h(B, { style: quietButton, onClick: resetTimes }, '全部恢复自动时间') : null,
|
|
1717
|
+
h(B, { style: button, onClick: () => setMergeDialog(true), disabled: editing }, '整理字幕'),
|
|
1718
|
+
h(B, { style: button, onClick: resplitNow, disabled: editing || translateBusy }, '智能拆分'),
|
|
1719
|
+
h(B, { style: button, onClick: openQuality, disabled: !detail.cueList || detail.cueList.length === 0 }, '质量报告'),
|
|
1720
|
+
h(B, { style: quietButton, onClick: () => setAudioDialog(true) }, '删除音频'),
|
|
1565
1721
|
),
|
|
1566
1722
|
!editing && review && review.batches > 0 && review.translated < review.batches
|
|
1567
1723
|
? h(
|
|
@@ -1616,6 +1772,12 @@ window.__ModuleLoader__.load({
|
|
|
1616
1772
|
h('input', { type: 'checkbox', checked: proofread, onChange: (event) => setProofread(event.target.checked) }),
|
|
1617
1773
|
'同时校正日文识别',
|
|
1618
1774
|
),
|
|
1775
|
+
h(
|
|
1776
|
+
'label',
|
|
1777
|
+
{ style: { display: 'flex', gap: 4, alignItems: 'center', fontSize: 11, color: tokens.muted } },
|
|
1778
|
+
h('input', { type: 'checkbox', checked: fastTranslate, onChange: (event) => setFastTranslate(event.target.checked) }),
|
|
1779
|
+
'并发翻译(更快,可能触发限流)',
|
|
1780
|
+
),
|
|
1619
1781
|
),
|
|
1620
1782
|
translateError
|
|
1621
1783
|
? h(
|
|
@@ -1967,12 +2129,141 @@ window.__ModuleLoader__.load({
|
|
|
1967
2129
|
{ key: 'glossbar', style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1968
2130
|
h(B, { style: button, onClick: importGlossary }, '导入粘贴的术语'),
|
|
1969
2131
|
h(B, { style: button, onClick: exportGlossary }, '导出 CSV'),
|
|
2132
|
+
h(B, { style: button, onClick: absorbTerms }, '把本项目术语存为常用'),
|
|
2133
|
+
),
|
|
2134
|
+
h('div', { key: 'lib-h3', style: { ...sectionTitle, marginTop: 16 } }, '常用术语(跨项目,' + library.terms.length + ' 条)'),
|
|
2135
|
+
library.terms.length > 0
|
|
2136
|
+
? h(
|
|
2137
|
+
'div',
|
|
2138
|
+
{ key: 'lib-terms', style: { maxHeight: 140, overflow: 'auto', marginTop: 6 } },
|
|
2139
|
+
library.terms.map((term) =>
|
|
2140
|
+
h(
|
|
2141
|
+
'div',
|
|
2142
|
+
{ key: 'lib-' + term.jp, style: { ...code, display: 'flex', justifyContent: 'space-between', gap: 6, padding: '2px 0' } },
|
|
2143
|
+
h('span', null, term.jp + ' → ' + term.zh),
|
|
2144
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => libraryAction({ action: 'remove-term', jp: term.jp }) }, '×'),
|
|
2145
|
+
),
|
|
2146
|
+
),
|
|
2147
|
+
)
|
|
2148
|
+
: h('div', { key: 'lib-empty', style: { ...code, opacity: 0.7 } }, '还没有常用术语;可以添加,或把本项目术语存进来'),
|
|
2149
|
+
h(
|
|
2150
|
+
'div',
|
|
2151
|
+
{ key: 'lib-add', style: { display: 'flex', gap: 6, marginTop: 6 } },
|
|
2152
|
+
h('input', { style: { ...input, flex: 1 }, value: libJp, placeholder: '日文', onChange: (event) => setLibJp(event.target.value) }),
|
|
2153
|
+
h('input', { style: { ...input, flex: 1 }, value: libZh, placeholder: '中文', onChange: (event) => setLibZh(event.target.value) }),
|
|
2154
|
+
h(B, { style: button, onClick: addLibraryTerm }, '添加'),
|
|
2155
|
+
),
|
|
2156
|
+
h('div', { key: 'hint-h3', style: { ...sectionTitle, marginTop: 16 } }, '背景模板(' + library.hints.length + ' 个)'),
|
|
2157
|
+
library.hints.length > 0
|
|
2158
|
+
? h(
|
|
2159
|
+
'div',
|
|
2160
|
+
{ key: 'hint-list', style: { maxHeight: 140, overflow: 'auto', marginTop: 6 } },
|
|
2161
|
+
library.hints.map((preset) =>
|
|
2162
|
+
h(
|
|
2163
|
+
'div',
|
|
2164
|
+
{ key: 'hint-' + preset.name, style: { ...code, display: 'flex', justifyContent: 'space-between', gap: 6, padding: '2px 0' } },
|
|
2165
|
+
h('span', null, preset.name),
|
|
2166
|
+
h(
|
|
2167
|
+
'span',
|
|
2168
|
+
{ style: { display: 'flex', gap: 4 } },
|
|
2169
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => applyHintPreset(preset.name) }, '套用'),
|
|
2170
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => libraryAction({ action: 'remove-hint', name: preset.name }) }, '×'),
|
|
2171
|
+
),
|
|
2172
|
+
),
|
|
2173
|
+
),
|
|
2174
|
+
)
|
|
2175
|
+
: h('div', { key: 'hint-empty', style: { ...code, opacity: 0.7 } }, '还没有背景模板;可以把当前背景保存成模板'),
|
|
2176
|
+
h(
|
|
2177
|
+
'div',
|
|
2178
|
+
{ key: 'hint-save', style: { display: 'flex', gap: 6, marginTop: 6 } },
|
|
2179
|
+
h('input', { style: { ...input, flex: 1 }, value: hintName, placeholder: '模板名称,例如「日常对话」', onChange: (event) => setHintName(event.target.value) }),
|
|
2180
|
+
h(B, { style: button, onClick: saveCurrentHint }, '保存当前背景'),
|
|
1970
2181
|
),
|
|
1971
2182
|
],
|
|
1972
2183
|
actions: [h(B, { key: 'close', style: quietButton, onClick: () => setContextDialog(false) }, '关闭')],
|
|
1973
2184
|
})
|
|
1974
2185
|
: null,
|
|
1975
2186
|
|
|
2187
|
+
audioDialog
|
|
2188
|
+
? h(Modal, {
|
|
2189
|
+
title: '删除音频',
|
|
2190
|
+
subtitle: '识别结果和字幕都会保留,只删除项目目录里的 audio.wav',
|
|
2191
|
+
width: 'min(460px, 92vw)',
|
|
2192
|
+
onClose: () => setAudioDialog(false),
|
|
2193
|
+
children: h(
|
|
2194
|
+
'div',
|
|
2195
|
+
{ style: { fontSize: 12, lineHeight: 1.8, color: tokens.text } },
|
|
2196
|
+
'这个文件是转写时从视频里提取的音频,通常有几百 MB。删除后不能重新转写,但已有的 asr.json 和字幕不受影响。',
|
|
2197
|
+
),
|
|
2198
|
+
actions: [
|
|
2199
|
+
h(B, { key: 'remove', style: dangerButton, onClick: removeAudio }, '删除'),
|
|
2200
|
+
h(B, { key: 'cancel', style: quietButton, onClick: () => setAudioDialog(false) }, '取消'),
|
|
2201
|
+
],
|
|
2202
|
+
})
|
|
2203
|
+
: null,
|
|
2204
|
+
|
|
2205
|
+
qualityOpen
|
|
2206
|
+
? h(Modal, {
|
|
2207
|
+
title: '质量报告',
|
|
2208
|
+
subtitle: '自动扫描字幕里的常见问题,点关闭后可在「逐条修改」里处理',
|
|
2209
|
+
width: 'min(760px, 94vw)',
|
|
2210
|
+
height: '80vh',
|
|
2211
|
+
onClose: () => setQualityOpen(false),
|
|
2212
|
+
children: h(
|
|
2213
|
+
'div',
|
|
2214
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
2215
|
+
h(
|
|
2216
|
+
'div',
|
|
2217
|
+
{ style: { ...code, color: tokens.text } },
|
|
2218
|
+
quality && quality.total > 0
|
|
2219
|
+
? '共 ' + quality.total + ' 处:' + Object.entries(quality.counts).map(([type, count]) => type + ' ' + count).join(' · ')
|
|
2220
|
+
: '没有发现明显问题',
|
|
2221
|
+
),
|
|
2222
|
+
quality
|
|
2223
|
+
? h(
|
|
2224
|
+
'div',
|
|
2225
|
+
{ style: { flex: 1, overflow: 'auto', display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
2226
|
+
quality.items.map((item) =>
|
|
2227
|
+
h(
|
|
2228
|
+
'div',
|
|
2229
|
+
{ key: item.type + '-' + item.from + '-' + item.to, style: { ...code, padding: '4px 0', borderBottom: '1px solid ' + tokens.border } },
|
|
2230
|
+
h('span', { style: { color: tokens.muted } }, '[' + item.type + '] ' + (item.start !== undefined ? Math.floor(item.start / 60) + ':' + String(Math.floor(item.start % 60)).padStart(2, '0') : item.from + '-' + item.to) + ' '),
|
|
2231
|
+
h('span', null, String(item.zh || item.jp).slice(0, 80)),
|
|
2232
|
+
),
|
|
2233
|
+
),
|
|
2234
|
+
)
|
|
2235
|
+
: null,
|
|
2236
|
+
),
|
|
2237
|
+
actions: [h(B, { key: 'close', style: quietButton, onClick: () => setQualityOpen(false) }, '关闭')],
|
|
2238
|
+
})
|
|
2239
|
+
: null,
|
|
2240
|
+
|
|
2241
|
+
mergeDialog
|
|
2242
|
+
? h(Modal, {
|
|
2243
|
+
title: '整理字幕',
|
|
2244
|
+
subtitle: '先合并过短的相邻句,再按标点拆开过长的句子',
|
|
2245
|
+
width: 'min(560px, 92vw)',
|
|
2246
|
+
onClose: () => setMergeDialog(false),
|
|
2247
|
+
children: h(
|
|
2248
|
+
'div',
|
|
2249
|
+
{ style: { fontSize: 12, lineHeight: 1.8, color: tokens.text } },
|
|
2250
|
+
h('div', null, '第一步,合并满足全部条件的相邻两条:'),
|
|
2251
|
+
h('div', { style: { ...code, marginTop: 6, display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
2252
|
+
h('span', null, '· 时间间隔不超过 0.8 秒'),
|
|
2253
|
+
h('span', null, '· 两条各自不超过 10 个汉字'),
|
|
2254
|
+
h('span', null, '· 合并后不超过 24 个汉字'),
|
|
2255
|
+
h('span', null, '· 跳过段、手动时间、空中文都不参与'),
|
|
2256
|
+
),
|
|
2257
|
+
h('div', { style: { ...code, marginTop: 8 } }, '第二步,把超过 24 个汉字的句子按标点拆成多条,时间按字数比例分配,跨度过大的长句会变成几条短句。'),
|
|
2258
|
+
h('div', { style: { ...code, marginTop: 6 } }, '两步都保持连续覆盖;原文件会备份为 cues.json.bak,可在「逐条修改」里再调整。'),
|
|
2259
|
+
),
|
|
2260
|
+
actions: [
|
|
2261
|
+
h(B, { key: 'merge', style: primary, onClick: tidySubtitles }, '开始整理'),
|
|
2262
|
+
h(B, { key: 'cancel', style: quietButton, onClick: () => setMergeDialog(false) }, '取消'),
|
|
2263
|
+
],
|
|
2264
|
+
})
|
|
2265
|
+
: null,
|
|
2266
|
+
|
|
1976
2267
|
helpDialog
|
|
1977
2268
|
? h(Modal, {
|
|
1978
2269
|
title: '使用说明',
|
|
@@ -2022,7 +2313,7 @@ window.__ModuleLoader__.load({
|
|
|
2022
2313
|
key: 'dir',
|
|
2023
2314
|
style: input,
|
|
2024
2315
|
value: projectsDraft,
|
|
2025
|
-
placeholder: '例如
|
|
2316
|
+
placeholder: '例如 %USERPROFILE%\\Documents\\DshSubtitle\\projects',
|
|
2026
2317
|
onChange: (event) => setProjectsDraft(event.target.value),
|
|
2027
2318
|
}),
|
|
2028
2319
|
h(
|
|
@@ -2091,7 +2382,7 @@ window.__ModuleLoader__.load({
|
|
|
2091
2382
|
key: 'path',
|
|
2092
2383
|
style: input,
|
|
2093
2384
|
value: componentPath,
|
|
2094
|
-
placeholder: '目录路径,例如
|
|
2385
|
+
placeholder: '目录路径,例如 %ProgramFiles%\\ffmpeg\\bin',
|
|
2095
2386
|
onChange: (event) => setComponentPath(event.target.value),
|
|
2096
2387
|
})
|
|
2097
2388
|
: null,
|
|
@@ -2129,8 +2420,18 @@ window.__ModuleLoader__.load({
|
|
|
2129
2420
|
})
|
|
2130
2421
|
: null,
|
|
2131
2422
|
|
|
2132
|
-
|
|
2133
|
-
|
|
2423
|
+
h(
|
|
2424
|
+
'div',
|
|
2425
|
+
{ style: { minHeight: 18, marginTop: 4 } },
|
|
2426
|
+
notice
|
|
2427
|
+
? h(
|
|
2428
|
+
'div',
|
|
2429
|
+
{ style: { ...code, maxWidth: '100%', whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', wordBreak: 'break-word', userSelect: 'text' } },
|
|
2430
|
+
notice,
|
|
2431
|
+
)
|
|
2432
|
+
: null,
|
|
2433
|
+
error ? h('div', { style: { ...code, color: tokens.danger } }, '接口错误:' + error) : null,
|
|
2434
|
+
),
|
|
2134
2435
|
)
|
|
2135
2436
|
}
|
|
2136
2437
|
|
package/docs/REVIEW.md
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"version": 1,
|
|
12
12
|
"strict": false,
|
|
13
13
|
"terms": [
|
|
14
|
-
{ "jp": "
|
|
14
|
+
{ "jp": "山田さん", "zh": "山田さん", "kind": "name" },
|
|
15
15
|
{ "jp": "マスター", "zh": "老板", "kind": "term" }
|
|
16
16
|
],
|
|
17
17
|
"corrections": [
|
|
18
|
-
{ "from": "
|
|
18
|
+
{ "from": "伊藤", "to": "伊東", "reason": "ASR 误听" }
|
|
19
19
|
]
|
|
20
20
|
}
|
|
21
21
|
```
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
32
|
subtitle_glossary { project: "…", action: "export" } # 写到 <project>/glossary.csv
|
|
33
|
-
subtitle_glossary { project: "…", action: "import", path: "
|
|
33
|
+
subtitle_glossary { project: "…", action: "import", path: "<path>\\glossary.csv" }
|
|
34
34
|
subtitle_glossary { project: "…", action: "import", from: "https://example.com/glossary.csv" }
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -39,7 +39,7 @@ CSV 只有四列,第一行是表头:
|
|
|
39
39
|
```csv
|
|
40
40
|
type,jp,zh,note
|
|
41
41
|
term,マスター,老板,称呼
|
|
42
|
-
correction
|
|
42
|
+
correction,伊藤,伊東,ASR 误听
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
- `type` 为 `term` 时约束中文译法,为 `correction` 时替换日文;
|