dsh-ai-subtitle 0.3.3 → 0.4.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/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 +307 -20
- 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-06c'
|
|
14
14
|
function trace(message) {
|
|
15
15
|
try {
|
|
16
16
|
const payload = JSON.stringify({ msg: String(message).slice(0, 300) })
|
|
@@ -454,7 +454,12 @@ window.__ModuleLoader__.load({
|
|
|
454
454
|
const [contextDialog, setContextDialog] = useState(false)
|
|
455
455
|
const [glossaryInfo, setGlossaryInfo] = useState(null)
|
|
456
456
|
const [glossaryText, setGlossaryText] = useState('')
|
|
457
|
+
const [library, setLibrary] = useState({ terms: [], hints: [] })
|
|
458
|
+
const [libJp, setLibJp] = useState('')
|
|
459
|
+
const [libZh, setLibZh] = useState('')
|
|
460
|
+
const [hintName, setHintName] = useState('')
|
|
457
461
|
const [proofread, setProofread] = useState(true)
|
|
462
|
+
const [fastTranslate, setFastTranslate] = useState(false)
|
|
458
463
|
const [feedbackDraft, setFeedbackDraft] = useState({})
|
|
459
464
|
const [batchNote, setBatchNote] = useState('')
|
|
460
465
|
const [reviewBatch, setReviewBatch] = useState(null)
|
|
@@ -472,6 +477,10 @@ window.__ModuleLoader__.load({
|
|
|
472
477
|
const [projectsInfo, setProjectsInfo] = useState(null)
|
|
473
478
|
const [projectsDialog, setProjectsDialog] = useState(false)
|
|
474
479
|
const [helpDialog, setHelpDialog] = useState(false)
|
|
480
|
+
const [mergeDialog, setMergeDialog] = useState(false)
|
|
481
|
+
const [qualityOpen, setQualityOpen] = useState(false)
|
|
482
|
+
const [quality, setQuality] = useState(null)
|
|
483
|
+
const [audioDialog, setAudioDialog] = useState(false)
|
|
475
484
|
const [projectsDraft, setProjectsDraft] = useState('')
|
|
476
485
|
const [projectsMove, setProjectsMove] = useState(true)
|
|
477
486
|
const [places, setPlaces] = useState([])
|
|
@@ -586,6 +595,128 @@ window.__ModuleLoader__.load({
|
|
|
586
595
|
if (result.error) setNotice('打开失败:' + result.error)
|
|
587
596
|
}
|
|
588
597
|
|
|
598
|
+
const tidySubtitles = async () => {
|
|
599
|
+
if (!detail) return
|
|
600
|
+
const merged = await callApi('/review/merge', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
601
|
+
if (merged.error) {
|
|
602
|
+
setMergeDialog(false)
|
|
603
|
+
setNotice('整理失败(合并):' + merged.error)
|
|
604
|
+
return
|
|
605
|
+
}
|
|
606
|
+
const split = await callApi('/review/split', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
607
|
+
setMergeDialog(false)
|
|
608
|
+
if (split.error) {
|
|
609
|
+
setNotice('整理失败(拆分):' + split.error)
|
|
610
|
+
return
|
|
611
|
+
}
|
|
612
|
+
setNotice(
|
|
613
|
+
'整理完成:合并 ' + merged.merged + ' 处、拆分 ' + split.split + ' 处,' + merged.before + ' 条 → ' + split.after + ' 条',
|
|
614
|
+
)
|
|
615
|
+
await openProject(detail)
|
|
616
|
+
refresh()
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const removeAudio = async () => {
|
|
620
|
+
if (!detail) return
|
|
621
|
+
const result = await callApi('/project/audio', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
622
|
+
setAudioDialog(false)
|
|
623
|
+
if (result.error) {
|
|
624
|
+
setNotice('删除音频失败:' + result.error)
|
|
625
|
+
return
|
|
626
|
+
}
|
|
627
|
+
setNotice('已删除音频,释放 ' + Math.round(result.freed / 1024 / 1024) + ' MB')
|
|
628
|
+
refresh()
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
const openQuality = async () => {
|
|
632
|
+
if (!detail) return
|
|
633
|
+
const result = await callApi('/quality?dir=' + encodeURIComponent(detail.dir))
|
|
634
|
+
if (result.error) {
|
|
635
|
+
setNotice('质量报告:' + result.error)
|
|
636
|
+
return
|
|
637
|
+
}
|
|
638
|
+
setQuality(result)
|
|
639
|
+
setQualityOpen(true)
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const resplitNow = async () => {
|
|
643
|
+
if (!detail) return
|
|
644
|
+
setTranslateBusy(true)
|
|
645
|
+
setTranslateError('')
|
|
646
|
+
const result = await callApi('/review/resplit', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
647
|
+
if (result.error) {
|
|
648
|
+
setTranslateBusy(false)
|
|
649
|
+
setTranslateError(result.error)
|
|
650
|
+
return
|
|
651
|
+
}
|
|
652
|
+
setNotice('智能拆分已开始')
|
|
653
|
+
for (let tick = 0; tick < 900; tick += 1) {
|
|
654
|
+
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
655
|
+
const job = await callApi('/job?id=' + encodeURIComponent(result.jobId))
|
|
656
|
+
if (job.error) {
|
|
657
|
+
setNotice('智能拆分:' + job.error)
|
|
658
|
+
break
|
|
659
|
+
}
|
|
660
|
+
if (job.status === 'done') {
|
|
661
|
+
setNotice('智能拆分完成')
|
|
662
|
+
break
|
|
663
|
+
}
|
|
664
|
+
if (job.status === 'failed') {
|
|
665
|
+
setTranslateError(job.error || '未知错误')
|
|
666
|
+
setNotice('智能拆分失败')
|
|
667
|
+
break
|
|
668
|
+
}
|
|
669
|
+
if (job.status === 'cancelled') {
|
|
670
|
+
setNotice('智能拆分已取消')
|
|
671
|
+
break
|
|
672
|
+
}
|
|
673
|
+
setNotice('智能拆分中:' + (job.msg || job.pct + '%'))
|
|
674
|
+
}
|
|
675
|
+
setTranslateBusy(false)
|
|
676
|
+
await openProject(detail)
|
|
677
|
+
refresh()
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const libraryAction = async (payload) => {
|
|
681
|
+
const result = await callApi('/library', { method: 'POST', body: JSON.stringify({ dir: detail.dir, ...payload }) })
|
|
682
|
+
if (result.error) {
|
|
683
|
+
setNotice('常用术语:' + result.error)
|
|
684
|
+
return false
|
|
685
|
+
}
|
|
686
|
+
if (result.library) setLibrary(result.library)
|
|
687
|
+
return true
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const addLibraryTerm = async () => {
|
|
691
|
+
if (!libJp.trim() || !libZh.trim()) return
|
|
692
|
+
if (await libraryAction({ action: 'add-term', jp: libJp.trim(), zh: libZh.trim() })) {
|
|
693
|
+
setLibJp('')
|
|
694
|
+
setLibZh('')
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
const absorbTerms = async () => {
|
|
699
|
+
if (await libraryAction({ action: 'absorb-project' })) setNotice('已把本项目术语保存到常用术语')
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const applyHintPreset = async (name) => {
|
|
703
|
+
if (await libraryAction({ action: 'apply-hint', name })) {
|
|
704
|
+
setNotice('已套用背景模板:' + name)
|
|
705
|
+
await loadHints(detail.dir)
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
const saveCurrentHint = async () => {
|
|
710
|
+
const name = hintName.trim() || (hintsInfo && hintsInfo.tags.length ? hintsInfo.tags[0] : '')
|
|
711
|
+
if (!name) {
|
|
712
|
+
setNotice('先给背景模板起个名字')
|
|
713
|
+
return
|
|
714
|
+
}
|
|
715
|
+
if (await libraryAction({ action: 'save-hint', name, tags: hintsInfo ? hintsInfo.tags : [], note: hintsInfo ? hintsInfo.note : '' })) {
|
|
716
|
+
setNotice('已保存背景模板:' + name)
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
589
720
|
const loadProjectsInfo = async () => {
|
|
590
721
|
const info = await callApi('/settings')
|
|
591
722
|
if (!info.error) setProjectsInfo(info)
|
|
@@ -802,13 +933,14 @@ window.__ModuleLoader__.load({
|
|
|
802
933
|
return h('span', null, '翻译 ' + progress.translated + '/' + progress.batches + ' 批')
|
|
803
934
|
}
|
|
804
935
|
|
|
805
|
-
const exportProject = async (dir) => {
|
|
806
|
-
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir }) })
|
|
936
|
+
const exportProject = async (dir, location) => {
|
|
937
|
+
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir, location }) })
|
|
807
938
|
if (result.error) {
|
|
808
939
|
setNotice('导出失败:' + result.error)
|
|
809
940
|
return
|
|
810
941
|
}
|
|
811
|
-
|
|
942
|
+
const renamed = result.backup ? ';旧字幕已改名为 ' + result.backup : ''
|
|
943
|
+
setNotice('已导出 ' + result.stats.cues + ' 条字幕:' + result.out + renamed)
|
|
812
944
|
refresh()
|
|
813
945
|
}
|
|
814
946
|
|
|
@@ -832,7 +964,7 @@ window.__ModuleLoader__.load({
|
|
|
832
964
|
setTranslateNotice('翻译中…')
|
|
833
965
|
setTranslateError('')
|
|
834
966
|
try {
|
|
835
|
-
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate' }
|
|
967
|
+
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate', concurrency: fastTranslate ? 3 : 1 }
|
|
836
968
|
if (all) payload.all = true
|
|
837
969
|
else if (reviewBatch) payload.batch = reviewBatch.batch
|
|
838
970
|
if (llmRoute && llmRoute.active) {
|
|
@@ -850,6 +982,7 @@ window.__ModuleLoader__.load({
|
|
|
850
982
|
setNotice('开始翻译:共 ' + result.total + ' 批')
|
|
851
983
|
setTranslateNotice('准备中…')
|
|
852
984
|
const dir = detail.dir
|
|
985
|
+
let jobError = ''
|
|
853
986
|
for (let tick = 0; tick < 900; tick += 1) {
|
|
854
987
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
855
988
|
const job = await callApi('/job?id=' + encodeURIComponent(result.jobId))
|
|
@@ -863,7 +996,7 @@ window.__ModuleLoader__.load({
|
|
|
863
996
|
}
|
|
864
997
|
if (job.status === 'failed') {
|
|
865
998
|
setNotice('翻译失败:' + (job.error || '未知错误'))
|
|
866
|
-
|
|
999
|
+
jobError = job.error || '未知错误'
|
|
867
1000
|
break
|
|
868
1001
|
}
|
|
869
1002
|
if (job.status === 'cancelled') {
|
|
@@ -874,7 +1007,8 @@ window.__ModuleLoader__.load({
|
|
|
874
1007
|
setTranslateNotice(job.msg || '翻译中…')
|
|
875
1008
|
}
|
|
876
1009
|
setTranslateJobId('')
|
|
877
|
-
await
|
|
1010
|
+
await openProject(detail)
|
|
1011
|
+
if (jobError) setTranslateError(jobError)
|
|
878
1012
|
refresh()
|
|
879
1013
|
return
|
|
880
1014
|
}
|
|
@@ -911,6 +1045,8 @@ window.__ModuleLoader__.load({
|
|
|
911
1045
|
const loadGlossaryInfo = async (dir) => {
|
|
912
1046
|
const result = await callApi('/glossary?dir=' + encodeURIComponent(dir))
|
|
913
1047
|
if (!result.error) setGlossaryInfo(result.glossary)
|
|
1048
|
+
const lib = await callApi('/library?dir=' + encodeURIComponent(dir))
|
|
1049
|
+
if (!lib.error) setLibrary(lib.library)
|
|
914
1050
|
}
|
|
915
1051
|
|
|
916
1052
|
const openContextDialog = async () => {
|
|
@@ -1107,14 +1243,15 @@ window.__ModuleLoader__.load({
|
|
|
1107
1243
|
openProject(detail)
|
|
1108
1244
|
}
|
|
1109
1245
|
|
|
1110
|
-
const exportSrt = async () => {
|
|
1246
|
+
const exportSrt = async (location) => {
|
|
1111
1247
|
if (!detail) return
|
|
1112
|
-
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir: detail.dir }) })
|
|
1248
|
+
const result = await callApi('/export', { method: 'POST', body: JSON.stringify({ dir: detail.dir, location }) })
|
|
1113
1249
|
if (result.error) {
|
|
1114
1250
|
setNotice('导出失败:' + result.error + (result.details ? '(' + result.details.join('; ') + ')' : ''))
|
|
1115
1251
|
return
|
|
1116
1252
|
}
|
|
1117
|
-
|
|
1253
|
+
const renamed = result.backup ? ';旧字幕已改名为 ' + result.backup : ''
|
|
1254
|
+
setNotice('已导出:' + result.out + '(' + result.stats.cues + ' 条)' + renamed)
|
|
1118
1255
|
openProject(detail)
|
|
1119
1256
|
refresh()
|
|
1120
1257
|
}
|
|
@@ -1342,7 +1479,7 @@ window.__ModuleLoader__.load({
|
|
|
1342
1479
|
h('input', {
|
|
1343
1480
|
style: { ...input, marginTop: 6 },
|
|
1344
1481
|
value: migrateTarget,
|
|
1345
|
-
placeholder: '目标目录,例如
|
|
1482
|
+
placeholder: '目标目录,例如 %LOCALAPPDATA%\\DshSubtitle',
|
|
1346
1483
|
onChange: (event) => setMigrateTarget(event.target.value),
|
|
1347
1484
|
}),
|
|
1348
1485
|
h(B, { style: { ...button, marginTop: 6 }, onClick: migrate }, '一键迁移'),
|
|
@@ -1361,7 +1498,7 @@ window.__ModuleLoader__.load({
|
|
|
1361
1498
|
h('input', {
|
|
1362
1499
|
style: input,
|
|
1363
1500
|
value: media,
|
|
1364
|
-
placeholder: '视频或音频的绝对路径,例如
|
|
1501
|
+
placeholder: '视频或音频的绝对路径,例如 %USERPROFILE%\\Videos\\foo.mp4',
|
|
1365
1502
|
onChange: (event) => setMedia(event.target.value),
|
|
1366
1503
|
}),
|
|
1367
1504
|
h(
|
|
@@ -1454,7 +1591,7 @@ window.__ModuleLoader__.load({
|
|
|
1454
1591
|
? h('div', { style: code }, '还没有项目,先在下面转写一个视频')
|
|
1455
1592
|
: h(
|
|
1456
1593
|
'div',
|
|
1457
|
-
{ style: { display: 'flex', flexDirection: 'column', gap: 6 } },
|
|
1594
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 'min(50vh, 480px)', overflowY: 'auto', paddingRight: 6, scrollbarWidth: 'thin' } },
|
|
1458
1595
|
visibleProjects.map((project) =>
|
|
1459
1596
|
h(
|
|
1460
1597
|
'div',
|
|
@@ -1474,10 +1611,20 @@ window.__ModuleLoader__.load({
|
|
|
1474
1611
|
style: { ...primary, padding: '4px 10px', flex: '0 0 auto' },
|
|
1475
1612
|
onClick: () => openProject(project),
|
|
1476
1613
|
}, project.review.translated === 0 ? '开始翻译' : '继续翻译')
|
|
1477
|
-
:
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1614
|
+
: [
|
|
1615
|
+
h(B, {
|
|
1616
|
+
key: 'export-project',
|
|
1617
|
+
style: { ...medium, flex: '0 0 auto' },
|
|
1618
|
+
title: '导出到项目目录',
|
|
1619
|
+
onClick: () => exportProject(project.dir),
|
|
1620
|
+
}, '导出到项目'),
|
|
1621
|
+
h(B, {
|
|
1622
|
+
key: 'export-video',
|
|
1623
|
+
style: { ...medium, flex: '0 0 auto' },
|
|
1624
|
+
title: '导出到视频目录,文件名与视频一致',
|
|
1625
|
+
onClick: () => exportProject(project.dir, 'video'),
|
|
1626
|
+
}, '导出到视频'),
|
|
1627
|
+
],
|
|
1481
1628
|
h(B, {
|
|
1482
1629
|
style: { ...button, padding: '6px 8px' },
|
|
1483
1630
|
title: project.pinned ? '取消置顶' : '置顶',
|
|
@@ -1546,7 +1693,8 @@ window.__ModuleLoader__.load({
|
|
|
1546
1693
|
h(
|
|
1547
1694
|
'div',
|
|
1548
1695
|
{ key: 'toolbar', style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1549
|
-
h(B, { style: primary, onClick: exportSrt }, '导出字幕'),
|
|
1696
|
+
h(B, { style: primary, onClick: () => exportSrt() }, '导出字幕'),
|
|
1697
|
+
h(B, { style: button, onClick: () => exportSrt('video') }, '导出到视频目录'),
|
|
1550
1698
|
h(B,
|
|
1551
1699
|
{
|
|
1552
1700
|
style: editing ? primary : button,
|
|
@@ -1562,6 +1710,10 @@ window.__ModuleLoader__.load({
|
|
|
1562
1710
|
? h(B, { style: primary, onClick: saveEdits }, '保存修改')
|
|
1563
1711
|
: h(B, { style: button, onClick: () => openProject(detail) }, '刷新'),
|
|
1564
1712
|
editing ? h(B, { style: quietButton, onClick: resetTimes }, '全部恢复自动时间') : null,
|
|
1713
|
+
h(B, { style: button, onClick: () => setMergeDialog(true), disabled: editing }, '整理字幕'),
|
|
1714
|
+
h(B, { style: button, onClick: resplitNow, disabled: editing || translateBusy }, '智能拆分'),
|
|
1715
|
+
h(B, { style: button, onClick: openQuality, disabled: !detail.cueList || detail.cueList.length === 0 }, '质量报告'),
|
|
1716
|
+
h(B, { style: quietButton, onClick: () => setAudioDialog(true) }, '删除音频'),
|
|
1565
1717
|
),
|
|
1566
1718
|
!editing && review && review.batches > 0 && review.translated < review.batches
|
|
1567
1719
|
? h(
|
|
@@ -1616,6 +1768,12 @@ window.__ModuleLoader__.load({
|
|
|
1616
1768
|
h('input', { type: 'checkbox', checked: proofread, onChange: (event) => setProofread(event.target.checked) }),
|
|
1617
1769
|
'同时校正日文识别',
|
|
1618
1770
|
),
|
|
1771
|
+
h(
|
|
1772
|
+
'label',
|
|
1773
|
+
{ style: { display: 'flex', gap: 4, alignItems: 'center', fontSize: 11, color: tokens.muted } },
|
|
1774
|
+
h('input', { type: 'checkbox', checked: fastTranslate, onChange: (event) => setFastTranslate(event.target.checked) }),
|
|
1775
|
+
'并发翻译(更快,可能触发限流)',
|
|
1776
|
+
),
|
|
1619
1777
|
),
|
|
1620
1778
|
translateError
|
|
1621
1779
|
? h(
|
|
@@ -1967,12 +2125,141 @@ window.__ModuleLoader__.load({
|
|
|
1967
2125
|
{ key: 'glossbar', style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1968
2126
|
h(B, { style: button, onClick: importGlossary }, '导入粘贴的术语'),
|
|
1969
2127
|
h(B, { style: button, onClick: exportGlossary }, '导出 CSV'),
|
|
2128
|
+
h(B, { style: button, onClick: absorbTerms }, '把本项目术语存为常用'),
|
|
2129
|
+
),
|
|
2130
|
+
h('div', { key: 'lib-h3', style: { ...sectionTitle, marginTop: 16 } }, '常用术语(跨项目,' + library.terms.length + ' 条)'),
|
|
2131
|
+
library.terms.length > 0
|
|
2132
|
+
? h(
|
|
2133
|
+
'div',
|
|
2134
|
+
{ key: 'lib-terms', style: { maxHeight: 140, overflow: 'auto', marginTop: 6 } },
|
|
2135
|
+
library.terms.map((term) =>
|
|
2136
|
+
h(
|
|
2137
|
+
'div',
|
|
2138
|
+
{ key: 'lib-' + term.jp, style: { ...code, display: 'flex', justifyContent: 'space-between', gap: 6, padding: '2px 0' } },
|
|
2139
|
+
h('span', null, term.jp + ' → ' + term.zh),
|
|
2140
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => libraryAction({ action: 'remove-term', jp: term.jp }) }, '×'),
|
|
2141
|
+
),
|
|
2142
|
+
),
|
|
2143
|
+
)
|
|
2144
|
+
: h('div', { key: 'lib-empty', style: { ...code, opacity: 0.7 } }, '还没有常用术语;可以添加,或把本项目术语存进来'),
|
|
2145
|
+
h(
|
|
2146
|
+
'div',
|
|
2147
|
+
{ key: 'lib-add', style: { display: 'flex', gap: 6, marginTop: 6 } },
|
|
2148
|
+
h('input', { style: { ...input, flex: 1 }, value: libJp, placeholder: '日文', onChange: (event) => setLibJp(event.target.value) }),
|
|
2149
|
+
h('input', { style: { ...input, flex: 1 }, value: libZh, placeholder: '中文', onChange: (event) => setLibZh(event.target.value) }),
|
|
2150
|
+
h(B, { style: button, onClick: addLibraryTerm }, '添加'),
|
|
2151
|
+
),
|
|
2152
|
+
h('div', { key: 'hint-h3', style: { ...sectionTitle, marginTop: 16 } }, '背景模板(' + library.hints.length + ' 个)'),
|
|
2153
|
+
library.hints.length > 0
|
|
2154
|
+
? h(
|
|
2155
|
+
'div',
|
|
2156
|
+
{ key: 'hint-list', style: { maxHeight: 140, overflow: 'auto', marginTop: 6 } },
|
|
2157
|
+
library.hints.map((preset) =>
|
|
2158
|
+
h(
|
|
2159
|
+
'div',
|
|
2160
|
+
{ key: 'hint-' + preset.name, style: { ...code, display: 'flex', justifyContent: 'space-between', gap: 6, padding: '2px 0' } },
|
|
2161
|
+
h('span', null, preset.name),
|
|
2162
|
+
h(
|
|
2163
|
+
'span',
|
|
2164
|
+
{ style: { display: 'flex', gap: 4 } },
|
|
2165
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => applyHintPreset(preset.name) }, '套用'),
|
|
2166
|
+
h(B, { style: { ...quietButton, padding: '0 6px' }, onClick: () => libraryAction({ action: 'remove-hint', name: preset.name }) }, '×'),
|
|
2167
|
+
),
|
|
2168
|
+
),
|
|
2169
|
+
),
|
|
2170
|
+
)
|
|
2171
|
+
: h('div', { key: 'hint-empty', style: { ...code, opacity: 0.7 } }, '还没有背景模板;可以把当前背景保存成模板'),
|
|
2172
|
+
h(
|
|
2173
|
+
'div',
|
|
2174
|
+
{ key: 'hint-save', style: { display: 'flex', gap: 6, marginTop: 6 } },
|
|
2175
|
+
h('input', { style: { ...input, flex: 1 }, value: hintName, placeholder: '模板名称,例如「日常对话」', onChange: (event) => setHintName(event.target.value) }),
|
|
2176
|
+
h(B, { style: button, onClick: saveCurrentHint }, '保存当前背景'),
|
|
1970
2177
|
),
|
|
1971
2178
|
],
|
|
1972
2179
|
actions: [h(B, { key: 'close', style: quietButton, onClick: () => setContextDialog(false) }, '关闭')],
|
|
1973
2180
|
})
|
|
1974
2181
|
: null,
|
|
1975
2182
|
|
|
2183
|
+
audioDialog
|
|
2184
|
+
? h(Modal, {
|
|
2185
|
+
title: '删除音频',
|
|
2186
|
+
subtitle: '识别结果和字幕都会保留,只删除项目目录里的 audio.wav',
|
|
2187
|
+
width: 'min(460px, 92vw)',
|
|
2188
|
+
onClose: () => setAudioDialog(false),
|
|
2189
|
+
children: h(
|
|
2190
|
+
'div',
|
|
2191
|
+
{ style: { fontSize: 12, lineHeight: 1.8, color: tokens.text } },
|
|
2192
|
+
'这个文件是转写时从视频里提取的音频,通常有几百 MB。删除后不能重新转写,但已有的 asr.json 和字幕不受影响。',
|
|
2193
|
+
),
|
|
2194
|
+
actions: [
|
|
2195
|
+
h(B, { key: 'remove', style: dangerButton, onClick: removeAudio }, '删除'),
|
|
2196
|
+
h(B, { key: 'cancel', style: quietButton, onClick: () => setAudioDialog(false) }, '取消'),
|
|
2197
|
+
],
|
|
2198
|
+
})
|
|
2199
|
+
: null,
|
|
2200
|
+
|
|
2201
|
+
qualityOpen
|
|
2202
|
+
? h(Modal, {
|
|
2203
|
+
title: '质量报告',
|
|
2204
|
+
subtitle: '自动扫描字幕里的常见问题,点关闭后可在「逐条修改」里处理',
|
|
2205
|
+
width: 'min(760px, 94vw)',
|
|
2206
|
+
height: '80vh',
|
|
2207
|
+
onClose: () => setQualityOpen(false),
|
|
2208
|
+
children: h(
|
|
2209
|
+
'div',
|
|
2210
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
2211
|
+
h(
|
|
2212
|
+
'div',
|
|
2213
|
+
{ style: { ...code, color: tokens.text } },
|
|
2214
|
+
quality && quality.total > 0
|
|
2215
|
+
? '共 ' + quality.total + ' 处:' + Object.entries(quality.counts).map(([type, count]) => type + ' ' + count).join(' · ')
|
|
2216
|
+
: '没有发现明显问题',
|
|
2217
|
+
),
|
|
2218
|
+
quality
|
|
2219
|
+
? h(
|
|
2220
|
+
'div',
|
|
2221
|
+
{ style: { flex: 1, overflow: 'auto', display: 'flex', flexDirection: 'column', gap: 4 } },
|
|
2222
|
+
quality.items.map((item) =>
|
|
2223
|
+
h(
|
|
2224
|
+
'div',
|
|
2225
|
+
{ key: item.type + '-' + item.from + '-' + item.to, style: { ...code, padding: '4px 0', borderBottom: '1px solid ' + tokens.border } },
|
|
2226
|
+
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) + ' '),
|
|
2227
|
+
h('span', null, String(item.zh || item.jp).slice(0, 80)),
|
|
2228
|
+
),
|
|
2229
|
+
),
|
|
2230
|
+
)
|
|
2231
|
+
: null,
|
|
2232
|
+
),
|
|
2233
|
+
actions: [h(B, { key: 'close', style: quietButton, onClick: () => setQualityOpen(false) }, '关闭')],
|
|
2234
|
+
})
|
|
2235
|
+
: null,
|
|
2236
|
+
|
|
2237
|
+
mergeDialog
|
|
2238
|
+
? h(Modal, {
|
|
2239
|
+
title: '整理字幕',
|
|
2240
|
+
subtitle: '先合并过短的相邻句,再按标点拆开过长的句子',
|
|
2241
|
+
width: 'min(560px, 92vw)',
|
|
2242
|
+
onClose: () => setMergeDialog(false),
|
|
2243
|
+
children: h(
|
|
2244
|
+
'div',
|
|
2245
|
+
{ style: { fontSize: 12, lineHeight: 1.8, color: tokens.text } },
|
|
2246
|
+
h('div', null, '第一步,合并满足全部条件的相邻两条:'),
|
|
2247
|
+
h('div', { style: { ...code, marginTop: 6, display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
2248
|
+
h('span', null, '· 时间间隔不超过 0.8 秒'),
|
|
2249
|
+
h('span', null, '· 两条各自不超过 10 个汉字'),
|
|
2250
|
+
h('span', null, '· 合并后不超过 24 个汉字'),
|
|
2251
|
+
h('span', null, '· 跳过段、手动时间、空中文都不参与'),
|
|
2252
|
+
),
|
|
2253
|
+
h('div', { style: { ...code, marginTop: 8 } }, '第二步,把超过 24 个汉字的句子按标点拆成多条,时间按字数比例分配,跨度过大的长句会变成几条短句。'),
|
|
2254
|
+
h('div', { style: { ...code, marginTop: 6 } }, '两步都保持连续覆盖;原文件会备份为 cues.json.bak,可在「逐条修改」里再调整。'),
|
|
2255
|
+
),
|
|
2256
|
+
actions: [
|
|
2257
|
+
h(B, { key: 'merge', style: primary, onClick: tidySubtitles }, '开始整理'),
|
|
2258
|
+
h(B, { key: 'cancel', style: quietButton, onClick: () => setMergeDialog(false) }, '取消'),
|
|
2259
|
+
],
|
|
2260
|
+
})
|
|
2261
|
+
: null,
|
|
2262
|
+
|
|
1976
2263
|
helpDialog
|
|
1977
2264
|
? h(Modal, {
|
|
1978
2265
|
title: '使用说明',
|
|
@@ -2022,7 +2309,7 @@ window.__ModuleLoader__.load({
|
|
|
2022
2309
|
key: 'dir',
|
|
2023
2310
|
style: input,
|
|
2024
2311
|
value: projectsDraft,
|
|
2025
|
-
placeholder: '例如
|
|
2312
|
+
placeholder: '例如 %USERPROFILE%\\Documents\\DshSubtitle\\projects',
|
|
2026
2313
|
onChange: (event) => setProjectsDraft(event.target.value),
|
|
2027
2314
|
}),
|
|
2028
2315
|
h(
|
|
@@ -2091,7 +2378,7 @@ window.__ModuleLoader__.load({
|
|
|
2091
2378
|
key: 'path',
|
|
2092
2379
|
style: input,
|
|
2093
2380
|
value: componentPath,
|
|
2094
|
-
placeholder: '目录路径,例如
|
|
2381
|
+
placeholder: '目录路径,例如 %ProgramFiles%\\ffmpeg\\bin',
|
|
2095
2382
|
onChange: (event) => setComponentPath(event.target.value),
|
|
2096
2383
|
})
|
|
2097
2384
|
: null,
|
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` 时替换日文;
|