dsh-ai-subtitle 0.3.2 → 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 +319 -19
- 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 -26
- package/src/quality.js +61 -0
- package/src/resplit.js +143 -0
- package/src/review.js +28 -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) })
|
|
@@ -448,12 +448,18 @@ window.__ModuleLoader__.load({
|
|
|
448
448
|
const [translateBusy, setTranslateBusy] = useState(false)
|
|
449
449
|
const [translateJobId, setTranslateJobId] = useState('')
|
|
450
450
|
const [translateNotice, setTranslateNotice] = useState('')
|
|
451
|
+
const [translateError, setTranslateError] = useState('')
|
|
451
452
|
const [hints, setHints] = useState({ tags: [], note: '' })
|
|
452
453
|
const [tagDraft, setTagDraft] = useState('')
|
|
453
454
|
const [contextDialog, setContextDialog] = useState(false)
|
|
454
455
|
const [glossaryInfo, setGlossaryInfo] = useState(null)
|
|
455
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('')
|
|
456
461
|
const [proofread, setProofread] = useState(true)
|
|
462
|
+
const [fastTranslate, setFastTranslate] = useState(false)
|
|
457
463
|
const [feedbackDraft, setFeedbackDraft] = useState({})
|
|
458
464
|
const [batchNote, setBatchNote] = useState('')
|
|
459
465
|
const [reviewBatch, setReviewBatch] = useState(null)
|
|
@@ -471,6 +477,10 @@ window.__ModuleLoader__.load({
|
|
|
471
477
|
const [projectsInfo, setProjectsInfo] = useState(null)
|
|
472
478
|
const [projectsDialog, setProjectsDialog] = useState(false)
|
|
473
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)
|
|
474
484
|
const [projectsDraft, setProjectsDraft] = useState('')
|
|
475
485
|
const [projectsMove, setProjectsMove] = useState(true)
|
|
476
486
|
const [places, setPlaces] = useState([])
|
|
@@ -585,6 +595,128 @@ window.__ModuleLoader__.load({
|
|
|
585
595
|
if (result.error) setNotice('打开失败:' + result.error)
|
|
586
596
|
}
|
|
587
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
|
+
|
|
588
720
|
const loadProjectsInfo = async () => {
|
|
589
721
|
const info = await callApi('/settings')
|
|
590
722
|
if (!info.error) setProjectsInfo(info)
|
|
@@ -801,13 +933,14 @@ window.__ModuleLoader__.load({
|
|
|
801
933
|
return h('span', null, '翻译 ' + progress.translated + '/' + progress.batches + ' 批')
|
|
802
934
|
}
|
|
803
935
|
|
|
804
|
-
const exportProject = async (dir) => {
|
|
805
|
-
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 }) })
|
|
806
938
|
if (result.error) {
|
|
807
939
|
setNotice('导出失败:' + result.error)
|
|
808
940
|
return
|
|
809
941
|
}
|
|
810
|
-
|
|
942
|
+
const renamed = result.backup ? ';旧字幕已改名为 ' + result.backup : ''
|
|
943
|
+
setNotice('已导出 ' + result.stats.cues + ' 条字幕:' + result.out + renamed)
|
|
811
944
|
refresh()
|
|
812
945
|
}
|
|
813
946
|
|
|
@@ -829,8 +962,9 @@ window.__ModuleLoader__.load({
|
|
|
829
962
|
if (!detail) return
|
|
830
963
|
setTranslateBusy(true)
|
|
831
964
|
setTranslateNotice('翻译中…')
|
|
965
|
+
setTranslateError('')
|
|
832
966
|
try {
|
|
833
|
-
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate' }
|
|
967
|
+
const payload = { dir: detail.dir, mode: proofread ? 'proofread' : 'translate', concurrency: fastTranslate ? 3 : 1 }
|
|
834
968
|
if (all) payload.all = true
|
|
835
969
|
else if (reviewBatch) payload.batch = reviewBatch.batch
|
|
836
970
|
if (llmRoute && llmRoute.active) {
|
|
@@ -840,6 +974,7 @@ window.__ModuleLoader__.load({
|
|
|
840
974
|
const result = await callApi('/review/translate', { method: 'POST', body: JSON.stringify(payload) })
|
|
841
975
|
if (result.error) {
|
|
842
976
|
setNotice('翻译失败:' + result.error)
|
|
977
|
+
setTranslateError(result.error)
|
|
843
978
|
return
|
|
844
979
|
}
|
|
845
980
|
if (result.jobId) {
|
|
@@ -847,6 +982,7 @@ window.__ModuleLoader__.load({
|
|
|
847
982
|
setNotice('开始翻译:共 ' + result.total + ' 批')
|
|
848
983
|
setTranslateNotice('准备中…')
|
|
849
984
|
const dir = detail.dir
|
|
985
|
+
let jobError = ''
|
|
850
986
|
for (let tick = 0; tick < 900; tick += 1) {
|
|
851
987
|
await new Promise((resolve) => setTimeout(resolve, 2000))
|
|
852
988
|
const job = await callApi('/job?id=' + encodeURIComponent(result.jobId))
|
|
@@ -860,6 +996,7 @@ window.__ModuleLoader__.load({
|
|
|
860
996
|
}
|
|
861
997
|
if (job.status === 'failed') {
|
|
862
998
|
setNotice('翻译失败:' + (job.error || '未知错误'))
|
|
999
|
+
jobError = job.error || '未知错误'
|
|
863
1000
|
break
|
|
864
1001
|
}
|
|
865
1002
|
if (job.status === 'cancelled') {
|
|
@@ -870,13 +1007,15 @@ window.__ModuleLoader__.load({
|
|
|
870
1007
|
setTranslateNotice(job.msg || '翻译中…')
|
|
871
1008
|
}
|
|
872
1009
|
setTranslateJobId('')
|
|
873
|
-
await
|
|
1010
|
+
await openProject(detail)
|
|
1011
|
+
if (jobError) setTranslateError(jobError)
|
|
874
1012
|
refresh()
|
|
875
1013
|
return
|
|
876
1014
|
}
|
|
877
1015
|
setNotice('已翻译批次 ' + result.batch + '(' + result.route + '),写入 ' + result.cues + ' 条' + (result.jpChanged ? ',校正日文 ' + result.jpChanged + ' 条' : ''))
|
|
878
1016
|
setFeedbackDraft({})
|
|
879
1017
|
setBatchNote('')
|
|
1018
|
+
setTranslateError('')
|
|
880
1019
|
await openProject(detail)
|
|
881
1020
|
} finally {
|
|
882
1021
|
setTranslateBusy(false)
|
|
@@ -906,6 +1045,8 @@ window.__ModuleLoader__.load({
|
|
|
906
1045
|
const loadGlossaryInfo = async (dir) => {
|
|
907
1046
|
const result = await callApi('/glossary?dir=' + encodeURIComponent(dir))
|
|
908
1047
|
if (!result.error) setGlossaryInfo(result.glossary)
|
|
1048
|
+
const lib = await callApi('/library?dir=' + encodeURIComponent(dir))
|
|
1049
|
+
if (!lib.error) setLibrary(lib.library)
|
|
909
1050
|
}
|
|
910
1051
|
|
|
911
1052
|
const openContextDialog = async () => {
|
|
@@ -1021,6 +1162,7 @@ window.__ModuleLoader__.load({
|
|
|
1021
1162
|
setReview(null)
|
|
1022
1163
|
setFeedbackDraft({})
|
|
1023
1164
|
setBatchNote('')
|
|
1165
|
+
setTranslateError('')
|
|
1024
1166
|
loadRoute()
|
|
1025
1167
|
loadHints(next.dir)
|
|
1026
1168
|
loadReview(next.dir)
|
|
@@ -1101,14 +1243,15 @@ window.__ModuleLoader__.load({
|
|
|
1101
1243
|
openProject(detail)
|
|
1102
1244
|
}
|
|
1103
1245
|
|
|
1104
|
-
const exportSrt = async () => {
|
|
1246
|
+
const exportSrt = async (location) => {
|
|
1105
1247
|
if (!detail) return
|
|
1106
|
-
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 }) })
|
|
1107
1249
|
if (result.error) {
|
|
1108
1250
|
setNotice('导出失败:' + result.error + (result.details ? '(' + result.details.join('; ') + ')' : ''))
|
|
1109
1251
|
return
|
|
1110
1252
|
}
|
|
1111
|
-
|
|
1253
|
+
const renamed = result.backup ? ';旧字幕已改名为 ' + result.backup : ''
|
|
1254
|
+
setNotice('已导出:' + result.out + '(' + result.stats.cues + ' 条)' + renamed)
|
|
1112
1255
|
openProject(detail)
|
|
1113
1256
|
refresh()
|
|
1114
1257
|
}
|
|
@@ -1336,7 +1479,7 @@ window.__ModuleLoader__.load({
|
|
|
1336
1479
|
h('input', {
|
|
1337
1480
|
style: { ...input, marginTop: 6 },
|
|
1338
1481
|
value: migrateTarget,
|
|
1339
|
-
placeholder: '目标目录,例如
|
|
1482
|
+
placeholder: '目标目录,例如 %LOCALAPPDATA%\\DshSubtitle',
|
|
1340
1483
|
onChange: (event) => setMigrateTarget(event.target.value),
|
|
1341
1484
|
}),
|
|
1342
1485
|
h(B, { style: { ...button, marginTop: 6 }, onClick: migrate }, '一键迁移'),
|
|
@@ -1355,7 +1498,7 @@ window.__ModuleLoader__.load({
|
|
|
1355
1498
|
h('input', {
|
|
1356
1499
|
style: input,
|
|
1357
1500
|
value: media,
|
|
1358
|
-
placeholder: '视频或音频的绝对路径,例如
|
|
1501
|
+
placeholder: '视频或音频的绝对路径,例如 %USERPROFILE%\\Videos\\foo.mp4',
|
|
1359
1502
|
onChange: (event) => setMedia(event.target.value),
|
|
1360
1503
|
}),
|
|
1361
1504
|
h(
|
|
@@ -1448,7 +1591,7 @@ window.__ModuleLoader__.load({
|
|
|
1448
1591
|
? h('div', { style: code }, '还没有项目,先在下面转写一个视频')
|
|
1449
1592
|
: h(
|
|
1450
1593
|
'div',
|
|
1451
|
-
{ 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' } },
|
|
1452
1595
|
visibleProjects.map((project) =>
|
|
1453
1596
|
h(
|
|
1454
1597
|
'div',
|
|
@@ -1468,10 +1611,20 @@ window.__ModuleLoader__.load({
|
|
|
1468
1611
|
style: { ...primary, padding: '4px 10px', flex: '0 0 auto' },
|
|
1469
1612
|
onClick: () => openProject(project),
|
|
1470
1613
|
}, project.review.translated === 0 ? '开始翻译' : '继续翻译')
|
|
1471
|
-
:
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
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
|
+
],
|
|
1475
1628
|
h(B, {
|
|
1476
1629
|
style: { ...button, padding: '6px 8px' },
|
|
1477
1630
|
title: project.pinned ? '取消置顶' : '置顶',
|
|
@@ -1540,7 +1693,8 @@ window.__ModuleLoader__.load({
|
|
|
1540
1693
|
h(
|
|
1541
1694
|
'div',
|
|
1542
1695
|
{ key: 'toolbar', style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1543
|
-
h(B, { style: primary, onClick: exportSrt }, '导出字幕'),
|
|
1696
|
+
h(B, { style: primary, onClick: () => exportSrt() }, '导出字幕'),
|
|
1697
|
+
h(B, { style: button, onClick: () => exportSrt('video') }, '导出到视频目录'),
|
|
1544
1698
|
h(B,
|
|
1545
1699
|
{
|
|
1546
1700
|
style: editing ? primary : button,
|
|
@@ -1556,6 +1710,10 @@ window.__ModuleLoader__.load({
|
|
|
1556
1710
|
? h(B, { style: primary, onClick: saveEdits }, '保存修改')
|
|
1557
1711
|
: h(B, { style: button, onClick: () => openProject(detail) }, '刷新'),
|
|
1558
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) }, '删除音频'),
|
|
1559
1717
|
),
|
|
1560
1718
|
!editing && review && review.batches > 0 && review.translated < review.batches
|
|
1561
1719
|
? h(
|
|
@@ -1610,7 +1768,20 @@ window.__ModuleLoader__.load({
|
|
|
1610
1768
|
h('input', { type: 'checkbox', checked: proofread, onChange: (event) => setProofread(event.target.checked) }),
|
|
1611
1769
|
'同时校正日文识别',
|
|
1612
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
|
+
),
|
|
1613
1777
|
),
|
|
1778
|
+
translateError
|
|
1779
|
+
? h(
|
|
1780
|
+
'div',
|
|
1781
|
+
{ style: { marginTop: 8, padding: 8, borderRadius: 6, border: '1px solid ' + tokens.danger, color: tokens.danger, fontSize: 11, lineHeight: 1.6, userSelect: 'text' } },
|
|
1782
|
+
'翻译失败:' + translateError,
|
|
1783
|
+
)
|
|
1784
|
+
: null,
|
|
1614
1785
|
reviewBatch && reviewBatch.cues && reviewBatch.cues.length > 0
|
|
1615
1786
|
? h(
|
|
1616
1787
|
'div',
|
|
@@ -1954,12 +2125,141 @@ window.__ModuleLoader__.load({
|
|
|
1954
2125
|
{ key: 'glossbar', style: { display: 'flex', gap: 6, marginTop: 8, flexWrap: 'wrap' } },
|
|
1955
2126
|
h(B, { style: button, onClick: importGlossary }, '导入粘贴的术语'),
|
|
1956
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 }, '保存当前背景'),
|
|
1957
2177
|
),
|
|
1958
2178
|
],
|
|
1959
2179
|
actions: [h(B, { key: 'close', style: quietButton, onClick: () => setContextDialog(false) }, '关闭')],
|
|
1960
2180
|
})
|
|
1961
2181
|
: null,
|
|
1962
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
|
+
|
|
1963
2263
|
helpDialog
|
|
1964
2264
|
? h(Modal, {
|
|
1965
2265
|
title: '使用说明',
|
|
@@ -2009,7 +2309,7 @@ window.__ModuleLoader__.load({
|
|
|
2009
2309
|
key: 'dir',
|
|
2010
2310
|
style: input,
|
|
2011
2311
|
value: projectsDraft,
|
|
2012
|
-
placeholder: '例如
|
|
2312
|
+
placeholder: '例如 %USERPROFILE%\\Documents\\DshSubtitle\\projects',
|
|
2013
2313
|
onChange: (event) => setProjectsDraft(event.target.value),
|
|
2014
2314
|
}),
|
|
2015
2315
|
h(
|
|
@@ -2078,7 +2378,7 @@ window.__ModuleLoader__.load({
|
|
|
2078
2378
|
key: 'path',
|
|
2079
2379
|
style: input,
|
|
2080
2380
|
value: componentPath,
|
|
2081
|
-
placeholder: '目录路径,例如
|
|
2381
|
+
placeholder: '目录路径,例如 %ProgramFiles%\\ffmpeg\\bin',
|
|
2082
2382
|
onChange: (event) => setComponentPath(event.target.value),
|
|
2083
2383
|
})
|
|
2084
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` 时替换日文;
|