feat: 更新 README 并添加清空字幕记录功能

- 更新 README 中的项目状态和下载链接
- 添加清空字幕记录的功能
- 优化字幕记录的导出和清空界面
- 更新代码以支持跨平台兼容性
- 添加开源协议
This commit is contained in:
himeditator
2025-06-22 00:17:43 +08:00
parent 42237a229c
commit e23249bc54
9 changed files with 69 additions and 11 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Chen Janai
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -2,19 +2,24 @@
<img src="./resources/icon.png" width="100px" height="100px"/> <img src="./resources/icon.png" width="100px" height="100px"/>
<h1 align="center">auto-caption</h1> <h1 align="center">auto-caption</h1>
<p>Auto Caption 是一个跨平台的视频播放和字幕显示软件。</p> <p>Auto Caption 是一个跨平台的视频播放和字幕显示软件。</p>
<b>项目还在初步开发阶段。</b> <b>项目初版已经开发完毕。</b>
</div> </div>
<hr> ![](./assets/01.png)
## 📥 下载 ## 📥 下载
暂无 [GitHub Releases](https://github.com/HiMeditator/auto-caption/releases)
## 📚 用户手册 ## 📚 用户手册
暂无 暂无
### 基本使用
目前仅提供 Windows 平台的可安装版本。如果使用默认的 Gummy 字幕引擎,需要获取阿里云百炼平台的 API KEY 并配置到环境变量中才能正常使用该模型相关教程:[获取API KEY](https://help.aliyun.com/zh/model-studio/get-api-key)、[将API Key配置到环境变量](https://help.aliyun.com/zh/model-studio/configure-api-key-through-environment-variables)。
对于开发者,可以自己创建新的字幕引擎。具体通信规范请参考源代码。
## ✨ 特性 ## ✨ 特性
- 丰富的字幕样式设置 - 丰富的字幕样式设置
@@ -39,7 +44,7 @@ npm install
> >
> 所谓的字幕引擎实际上是一个子程序,它会实时获取系统音频输入(录音)或输出(播放声音)的流式数据,并调用音频转文字的模型生成对应音频的字幕。生成的字幕通过 IPC 输出为转换为字符串的 JSON 数据,并返回给主程序。主程序读取字幕数据,处理后显示在窗口上。 > 所谓的字幕引擎实际上是一个子程序,它会实时获取系统音频输入(录音)或输出(播放声音)的流式数据,并调用音频转文字的模型生成对应音频的字幕。生成的字幕通过 IPC 输出为转换为字符串的 JSON 数据,并返回给主程序。主程序读取字幕数据,处理后显示在窗口上。
> >
>目前项目默认使用[阿里云 Gummy 模型](https://help.aliyun.com/zh/model-studio/gummy-speech-recognition-translation/),需要获取阿里云百炼平台的 API KEY 并配置到环境变量中才能正常使用该模型,相关介绍[获取API KEY](https://help.aliyun.com/zh/model-studio/get-api-key)、[将API Key配置到环境变量](https://help.aliyun.com/zh/model-studio/configure-api-key-through-environment-variables)。 >目前项目默认使用[阿里云 Gummy 模型](https://help.aliyun.com/zh/model-studio/gummy-speech-recognition-translation/),需要获取阿里云百炼平台的 API KEY 并配置到环境变量中才能正常使用该模型,相关教程[获取API KEY](https://help.aliyun.com/zh/model-studio/get-api-key)、[将API Key配置到环境变量](https://help.aliyun.com/zh/model-studio/configure-api-key-through-environment-variables)。
> >
> 本项目的 gummy 字幕引擎是一个 python 子程序,通过 pyinstaller 打包为可执行文件。 运行字幕引擎子程序的代码在 `src\main\utils\engine.ts` 文件中。 > 本项目的 gummy 字幕引擎是一个 python 子程序,通过 pyinstaller 打包为可执行文件。 运行字幕引擎子程序的代码在 `src\main\utils\engine.ts` 文件中。
@@ -55,10 +60,10 @@ python -m venv subenv
# Windows # Windows
subenv/Scripts/activate subenv/Scripts/activate
# Linux # Linux
source myenv/bin/activate source subenv/bin/activate
``` ```
然后安装依赖: 然后安装依赖(注意如果是 Linux 环境,需要注释调 `requirements.txt` 中的 `PyAudioWPatch`,该模块仅适用于 Windows 环境)
```bash ```bash
pip install -r requirements.txt pip install -r requirements.txt

BIN
assets/01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

View File

@@ -1,10 +1,10 @@
{ {
"name": "auto-caption", "name": "auto-caption",
"version": "0.0.1", "version": "0.0.1",
"description": "A cross-platform video playback and subtitle display software.", "description": "A cross-platform subtitle display software.",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "himeditator", "author": "himeditator",
"homepage": "https://electron-vite.org", "homepage": "https://github.com/HiMeditator/auto-caption",
"scripts": { "scripts": {
"format": "prettier --write .", "format": "prettier --write .",
"lint": "eslint --cache .", "lint": "eslint --cache .",

Binary file not shown.

View File

@@ -5,6 +5,7 @@ import icon from '../../resources/icon.png?asset'
import { captionWindow } from './caption' import { captionWindow } from './caption'
import { import {
captionEngine, captionEngine,
captionLog,
controls, controls,
setStyles, setStyles,
sendStyles, sendStyles,
@@ -98,6 +99,10 @@ class ControlWindow {
captionEngine.stop() captionEngine.stop()
this.window?.webContents.send('control.engine.stopped') this.window?.webContents.send('control.engine.stopped')
}) })
// 清空字幕记录
ipcMain.on('control.caption.clear', () => {
captionLog.splice(0)
})
} }
} }

View File

@@ -15,16 +15,26 @@ export class CaptionEngine {
this.command = [ controls.customizedCommand ] this.command = [ controls.customizedCommand ]
} }
else if(controls.engine === 'gummy'){ else if(controls.engine === 'gummy'){
let gummyName = ''
if(process.platform === 'win32'){
gummyName = 'main-gummy.exe'
}
else if(process.platform === 'linux'){
gummyName = 'main-gummy'
}
else{
throw new Error('Unsupported platform')
}
if(is.dev){ if(is.dev){
this.appPath = path.join( this.appPath = path.join(
app.getAppPath(), app.getAppPath(),
'python-subprocess', 'dist', 'main-gummy.exe' 'python-subprocess', 'dist', gummyName
) )
} }
else{ else{
this.appPath = path.join( this.appPath = path.join(
process.resourcesPath, process.resourcesPath,
'python-subprocess', 'dist', 'main-gummy.exe' 'python-subprocess', 'dist', gummyName
) )
} }
this.command = [] this.command = []

View File

@@ -34,11 +34,18 @@
<span style="margin-right: 30px;">字幕记录</span> <span style="margin-right: 30px;">字幕记录</span>
<a-button <a-button
type="primary" type="primary"
style="margin-right: 20px;"
@click="exportCaptions" @click="exportCaptions"
:disabled="captionData.length === 0" :disabled="captionData.length === 0"
> >
导出字幕记录 导出字幕记录
</a-button> </a-button>
<a-button
danger
@click="clearCaptions"
>
清空字幕记录
</a-button>
</div> </div>
<a-table <a-table
:columns="columns" :columns="columns"
@@ -128,6 +135,10 @@ function exportCaptions() {
document.body.removeChild(a) document.body.removeChild(a)
URL.revokeObjectURL(url) URL.revokeObjectURL(url)
} }
function clearCaptions() {
captionLog.clear()
}
</script> </script>
<style scoped> <style scoped>

View File

@@ -21,11 +21,17 @@ export const useCaptionLogStore = defineStore('captionLog', () => {
} }
}) })
function clear() {
captionData.value = []
window.electron.ipcRenderer.send('control.caption.clear')
}
window.electron.ipcRenderer.on('both.log.set', (_, logs) => { window.electron.ipcRenderer.on('both.log.set', (_, logs) => {
captionData.value = logs captionData.value = logs
}) })
return { return {
captionData captionData,
clear
} }
}) })