diff --git a/.gitignore b/.gitignore index c5e680d..6560132 100644 --- a/.gitignore +++ b/.gitignore @@ -7,15 +7,13 @@ out __pycache__ .venv test.py + engine/build -engine/dist -engine/.venv -engine/__pycache__ engine/portaudio -package-lock.json engine/pyinstaller_cache engine/models engine/notebook +# engine/main.spec + .repomap .virtualme -engine/main.spec diff --git a/README.md b/README.md index 1891aa9..e589ad7 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ SOSV 模型下载:[ Shepra-ONNX SenseVoice Model](https://github.com/HiMeditat - 支持调用本地 Ollama 模型或云端 Google 翻译 API 进行翻译 - 跨平台(Windows、macOS、Linux)、多界面语言(中文、英语、日语)支持 - 丰富的字幕样式设置(字体、字体大小、字体粗细、字体颜色、背景颜色等) -- 灵活的字幕引擎选择(阿里云 Gummy 云端模型、本地 Vosk 模型、本地 SOSV 模型、还可以自己开发模型) +- 灵活的字幕引擎选择(阿里云 Gummy 云端模型、GLM-ASR 云端模型、本地 Vosk 模型、本地 SOSV 模型、还可以自己开发模型) - 多语言识别与翻译(见下文“⚙️ 自带字幕引擎说明”) - 字幕记录展示与导出(支持导出 `.srt` 和 `.json` 格式) @@ -62,6 +62,7 @@ macOS 平台和 Linux 平台获取系统音频输出需要进行额外设置, | | 识别效果 | 部署类型 | 支持语言 | 翻译 | 备注 | | ------------------------------------------------------------ | -------- | ------------- | ---------- | ---------- | ---------------------------------------------------------- | | [Gummy](https://help.aliyun.com/zh/model-studio/gummy-speech-recognition-translation) | 很好😊 | 云端 / 阿里云 | 10 种 | 自带翻译 | 收费,0.54CNY / 小时 | +| [glm-asr-2512](https://docs.bigmodel.cn/cn/guide/models/sound-and-video/glm-asr-2512) | 很好😊 | 云端 / 智谱 AI | 4 种 | 需额外配置 | 收费,约 0.72CNY / 小时 | | [Vosk](https://alphacephei.com/vosk) | 较差😞 | 本地 / CPU | 超过 30 种 | 需额外配置 | 支持的语言非常多 | | [SOSV](https://k2-fsa.github.io/sherpa/onnx/sense-voice/index.html) | 一般😐 | 本地 / CPU | 5 种 | 需额外配置 | 仅有一个模型 | | 自己开发 | 🤔 | 自定义 | 自定义 | 自定义 | 根据[文档](./docs/engine-manual/zh.md)使用 Python 自己开发 | diff --git a/engine/utils/translation.py b/engine/utils/translation.py index 26aa3f2..e935d60 100644 --- a/engine/utils/translation.py +++ b/engine/utils/translation.py @@ -27,14 +27,14 @@ def ollama_translate(model: str, target: str, text: str, time_s: str, url: str = if url: if OpenAI: client = OpenAI(base_url=url, api_key=key if key else "ollama") - response = client.chat.completions.create( + openai_response = client.chat.completions.create( model=model, messages=[ {"role": "system", "content": f"/no_think Translate the following content into {lang_map[target]}, and do not output any additional information."}, {"role": "user", "content": text} ] ) - content = response.choices[0].message.content or "" + content = openai_response.choices[0].message.content or "" else: client = Client(host=url) response: ChatResponse = client.chat( diff --git a/package.json b/package.json index 97e8cb2..0bb548a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "auto-caption", "productName": "Auto Caption", - "version": "1.0.0", + "version": "1.1.0", "description": "A cross-platform subtitle display software.", "main": "./out/main/index.js", "author": "himeditator", diff --git a/src/main/utils/AllConfig.ts b/src/main/utils/AllConfig.ts index 790b83a..9fe82a7 100644 --- a/src/main/utils/AllConfig.ts +++ b/src/main/utils/AllConfig.ts @@ -4,6 +4,7 @@ import { } from '../types' import { Log } from './Log' import { app, BrowserWindow } from 'electron' +import { passwordMaskingForObject } from './UtilsFunc' import * as path from 'path' import * as fs from 'fs' import * as os from 'os' @@ -151,9 +152,7 @@ class AllConfig { } } this.controls.engineEnabled = engineEnabled - let _controls = {...this.controls} - _controls.API_KEY = _controls.API_KEY.replace(/./g, '*') - Log.info('Set Controls:', _controls) + Log.info('Set Controls:', passwordMaskingForObject(this.controls)) } public sendControls(window: BrowserWindow, info = true) { diff --git a/src/main/utils/CaptionEngine.ts b/src/main/utils/CaptionEngine.ts index 1dadbb4..d6d5bb5 100644 --- a/src/main/utils/CaptionEngine.ts +++ b/src/main/utils/CaptionEngine.ts @@ -7,6 +7,7 @@ import { controlWindow } from '../ControlWindow' import { allConfig } from './AllConfig' import { i18n } from '../i18n' import { Log } from './Log' +import { passwordMaskingForList } from './UtilsFunc' export class CaptionEngine { appPath: string = '' @@ -114,12 +115,7 @@ export class CaptionEngine { } } Log.info('Engine Path:', this.appPath) - if(this.command.length > 2 && this.command[this.command.length - 2] === '-k') { - const _command = [...this.command] - _command[_command.length -1] = _command[_command.length -1].replace(/./g, '*') - Log.info('Engine Command:', _command) - } - else Log.info('Engine Command:', this.command) + Log.info('Engine Command:', passwordMaskingForList(this.command)) return true } @@ -182,7 +178,7 @@ export class CaptionEngine { const data_obj = JSON.parse(line) handleEngineData(data_obj) } catch (e) { - controlWindow.sendErrorMessage(i18n('engine.output.parse.error') + e) + // controlWindow.sendErrorMessage(i18n('engine.output.parse.error') + e) Log.error('Error parsing JSON:', e) } } diff --git a/src/main/utils/UtilsFunc.ts b/src/main/utils/UtilsFunc.ts new file mode 100644 index 0000000..09cd890 --- /dev/null +++ b/src/main/utils/UtilsFunc.ts @@ -0,0 +1,24 @@ +function passwordMasking(pwd: string) { + return pwd.replace(/./g, '*') +} + +export function passwordMaskingForList(args: string[]) { + const maskedArgs = [...args] + for(let i = 1; i < maskedArgs.length; i++) { + if(maskedArgs[i-1] === '-k' || maskedArgs[i-1] === '-okey' || maskedArgs[i-1] === '-gkey') { + maskedArgs[i] = passwordMasking(maskedArgs[i]) + } + } + return maskedArgs +} + +export function passwordMaskingForObject(args: Record) { + const maskedArgs = {...args} + for(const key in maskedArgs) { + const lKey = key.toLowerCase() + if(lKey.includes('api') && lKey.includes('key')) { + maskedArgs[key] = passwordMasking(maskedArgs[key]) + } + } + return maskedArgs +} diff --git a/src/renderer/index.html b/src/renderer/index.html index 538c49c..1d6c1eb 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -2,7 +2,7 @@ - Auto Caption v1.0.0 + Auto Caption v1.1.0 {{ $t('engine.ollama') }} + >{{ $t('engine.modelName') }}
- Ollama Domain + + + Base URL +
- Ollama API Key - + + + API Key + +
GLM API URL @@ -83,13 +98,6 @@ placeholder="glm-asr-2512" >
-
- GLM API Key - -
{{ $t('engine.audioType') }} {{ $t('engine.apikey') }} + >ALI {{ $t('engine.apikey') }}
+
+ + + GLM {{ $t('engine.apikey') }} + + +