diff --git a/.gitignore b/.gitignore index 42e7241..8ad69a7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ test.py engine/build engine/models engine/notebook +.repomap +.virtualme diff --git a/docs/TODO.md b/docs/TODO.md index 3a14d6b..986a779 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -18,9 +18,13 @@ - [x] 添加字幕记录按时间降序排列选择 *2025/07/26* - [x] 重构字幕引擎 *2025/07/28* - [x] 优化前端界面提示消息 *2025/07/29* +- [x] 复制字幕记录可选择只复制最近的字幕记录 *2025/08/18* +- [x] 添加颜色主题设置 *2025/08/18* ## 待完成 +- [ ] 前端页面添加日志内容展示 +- [ ] 调研更多的云端模型(火山、OpenAI、Google等) - [ ] 验证 / 添加基于 sherpa-onnx 的字幕引擎 ## 后续计划 diff --git a/docs/api-docs/electron-ipc.md b/docs/api-docs/electron-ipc.md index 1397318..07aa240 100644 --- a/docs/api-docs/electron-ipc.md +++ b/docs/api-docs/electron-ipc.md @@ -84,7 +84,7 @@ ### `control.uiTheme.change` -**介绍:** 前端修改字界面主题,将修改同步给后端 +**介绍:** 前端修改界面主题,将修改同步给后端 **发起方:** 前端控制窗口 @@ -92,6 +92,16 @@ **数据类型:** `UITheme` +### `control.uiColor.change` + +**介绍:** 前端修改界面主题颜色,将修改同步给后端 + +**发起方:** 前端控制窗口 + +**接收方:** 后端控制窗口实例 + +**数据类型:** `string` + ### `control.leftBarWidth.change` **介绍:** 前端修改边栏宽度,将修改同步给后端 diff --git a/engine/utils/audioprcs.py b/engine/utils/audioprcs.py index 1169bb8..d1e664a 100644 --- a/engine/utils/audioprcs.py +++ b/engine/utils/audioprcs.py @@ -55,7 +55,7 @@ def resample_chunk_mono(chunk: bytes, channels: int, orig_sr: int, target_sr: in return chunk_mono_r.tobytes() -def resample_chunk_mono_np(chunk: bytes, channels: int, orig_sr: int, target_sr: int, mode="sinc_best") -> np.ndarray: +def resample_chunk_mono_np(chunk: bytes, channels: int, orig_sr: int, target_sr: int, mode="sinc_best", dtype=np.float32) -> np.ndarray: """ 将当前多通道音频数据块转换成单通道音频数据块,然后进行重采样,返回 Numpy 数组 @@ -65,6 +65,7 @@ def resample_chunk_mono_np(chunk: bytes, channels: int, orig_sr: int, target_sr: orig_sr: 原始采样率 target_sr: 目标采样率 mode: 重采样模式,可选:'sinc_best' | 'sinc_medium' | 'sinc_fastest' | 'zero_order_hold' | 'linear' + dtype: 返回 Numpy 数组的数据类型 Return: 单通道音频数据块 @@ -82,7 +83,7 @@ def resample_chunk_mono_np(chunk: bytes, channels: int, orig_sr: int, target_sr: ratio = target_sr / orig_sr chunk_mono_r = samplerate.resample(chunk_mono, ratio, converter_type=mode) - chunk_mono_r = np.round(chunk_mono_r).astype(np.int16) + chunk_mono_r = chunk_mono_r.astype(dtype) return chunk_mono_r diff --git a/src/main/ControlWindow.ts b/src/main/ControlWindow.ts index 0480c14..db3b236 100644 --- a/src/main/ControlWindow.ts +++ b/src/main/ControlWindow.ts @@ -109,6 +109,10 @@ class ControlWindow { allConfig.uiTheme = args }) + ipcMain.on('control.uiColor.change', (_, args) => { + allConfig.uiColor = args + }) + ipcMain.on('control.leftBarWidth.change', (_, args) => { allConfig.leftBarWidth = args }) diff --git a/src/main/types/index.ts b/src/main/types/index.ts index 458a72d..241725d 100644 --- a/src/main/types/index.ts +++ b/src/main/types/index.ts @@ -49,6 +49,7 @@ export interface FullConfig { platform: string, uiLanguage: UILanguage, uiTheme: UITheme, + uiColor: string, leftBarWidth: number, styles: Styles, controls: Controls, diff --git a/src/main/utils/AllConfig.ts b/src/main/utils/AllConfig.ts index 310564a..ffb97bf 100644 --- a/src/main/utils/AllConfig.ts +++ b/src/main/utils/AllConfig.ts @@ -49,6 +49,7 @@ class AllConfig { uiLanguage: UILanguage = 'zh'; leftBarWidth: number = 8; uiTheme: UITheme = 'system'; + uiColor: string = '#1677ff'; styles: Styles = {...defaultStyles}; controls: Controls = {...defaultControls}; @@ -64,6 +65,7 @@ class AllConfig { if(config.captionWindowWidth) this.captionWindowWidth = config.captionWindowWidth if(config.uiLanguage) this.uiLanguage = config.uiLanguage if(config.uiTheme) this.uiTheme = config.uiTheme + if(config.uiColor) this.uiColor = config.uiColor if(config.leftBarWidth) this.leftBarWidth = config.leftBarWidth if(config.styles) this.setStyles(config.styles) if(config.controls) this.setControls(config.controls) @@ -76,6 +78,7 @@ class AllConfig { captionWindowWidth: this.captionWindowWidth, uiLanguage: this.uiLanguage, uiTheme: this.uiTheme, + uiColor: this.uiColor, leftBarWidth: this.leftBarWidth, controls: this.controls, styles: this.styles @@ -90,6 +93,7 @@ class AllConfig { platform: process.platform, uiLanguage: this.uiLanguage, uiTheme: this.uiTheme, + uiColor: this.uiColor, leftBarWidth: this.leftBarWidth, styles: this.styles, controls: this.controls, @@ -123,7 +127,9 @@ class AllConfig { } } this.controls.engineEnabled = engineEnabled - Log.info('Set Controls:', this.controls) + let _controls = {...this.controls} + _controls.API_KEY = _controls.API_KEY.replace(/./g, '*') + Log.info('Set Controls:', _controls) } public sendControls(window: BrowserWindow, info = true) { diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 637ffe3..fbd8a51 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -14,6 +14,7 @@ onMounted(() => { window.electron.ipcRenderer.invoke('both.window.mounted').then((data: FullConfig) => { useGeneralSettingStore().uiLanguage = data.uiLanguage useGeneralSettingStore().uiTheme = data.uiTheme + useGeneralSettingStore().uiColor = data.uiColor useGeneralSettingStore().leftBarWidth = data.leftBarWidth useCaptionStyleStore().setStyles(data.styles) useEngineControlStore().platform = data.platform diff --git a/src/renderer/src/assets/input.css b/src/renderer/src/assets/input.css index 018e1de..da7cfd3 100644 --- a/src/renderer/src/assets/input.css +++ b/src/renderer/src/assets/input.css @@ -17,6 +17,7 @@ } .input-area { + display: inline-block; width: calc(100% - 100px); min-width: 100px; } diff --git a/src/renderer/src/components/CaptionLog.vue b/src/renderer/src/components/CaptionLog.vue index ac416d6..5dace1d 100644 --- a/src/renderer/src/components/CaptionLog.vue +++ b/src/renderer/src/components/CaptionLog.vue @@ -55,8 +55,8 @@
.srt.json[:][-1:][-2:][-3:]