mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-14 03:24:44 +08:00
feat(renderer): 在用户界面中添加新功能的设置
- 添加录音功能,可保存为 WAV 文件 - 优化字幕引擎设置界面,支持更多配置选项 - 更新多语言翻译,增加模型下载链接等信息
This commit is contained in:
@@ -11,8 +11,11 @@ export interface Controls {
|
||||
engine: string,
|
||||
audio: 0 | 1,
|
||||
translation: boolean,
|
||||
recording: boolean,
|
||||
API_KEY: string,
|
||||
modelPath: string,
|
||||
voskModelPath: string,
|
||||
sosvModelPath: string,
|
||||
recordingPath: string,
|
||||
customized: boolean,
|
||||
customizedApp: string,
|
||||
customizedCommand: string,
|
||||
|
||||
@@ -6,12 +6,18 @@ import { Log } from './Log'
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import os from 'os'
|
||||
|
||||
interface CaptionTranslation {
|
||||
time_s: string,
|
||||
translation: string
|
||||
}
|
||||
|
||||
function getDesktopPath() {
|
||||
const homeDir = os.homedir()
|
||||
return path.join(homeDir, 'Desktop')
|
||||
}
|
||||
|
||||
const defaultStyles: Styles = {
|
||||
lineBreak: 1,
|
||||
fontFamily: 'sans-serif',
|
||||
@@ -42,8 +48,11 @@ const defaultControls: Controls = {
|
||||
audio: 0,
|
||||
engineEnabled: false,
|
||||
API_KEY: '',
|
||||
modelPath: '',
|
||||
voskModelPath: '',
|
||||
sosvModelPath: '',
|
||||
recordingPath: getDesktopPath(),
|
||||
translation: true,
|
||||
recording: false,
|
||||
customized: false,
|
||||
customizedApp: '',
|
||||
customizedCommand: '',
|
||||
|
||||
@@ -63,8 +63,11 @@ export class CaptionEngine {
|
||||
this.appPath = path.join(process.resourcesPath, 'engine', 'main')
|
||||
}
|
||||
}
|
||||
|
||||
this.command.push('-a', allConfig.controls.audio ? '1' : '0')
|
||||
if(allConfig.controls.recording) {
|
||||
this.command.push('-r', '1')
|
||||
this.command.push('-rp', allConfig.controls.recordingPath)
|
||||
}
|
||||
this.port = Math.floor(Math.random() * (65535 - 1024 + 1)) + 1024
|
||||
this.command.push('-p', this.port.toString())
|
||||
this.command.push(
|
||||
@@ -81,7 +84,14 @@ export class CaptionEngine {
|
||||
}
|
||||
else if(allConfig.controls.engine === 'vosk'){
|
||||
this.command.push('-e', 'vosk')
|
||||
this.command.push('-vosk', `"${allConfig.controls.modelPath}"`)
|
||||
this.command.push('-vosk', `"${allConfig.controls.voskModelPath}"`)
|
||||
this.command.push('-tm', allConfig.controls.transModel)
|
||||
this.command.push('-omn', allConfig.controls.ollamaName)
|
||||
}
|
||||
else if(allConfig.controls.engine === 'sosv'){
|
||||
this.command.push('-e', 'sosv')
|
||||
this.command.push('-s', allConfig.controls.sourceLang)
|
||||
this.command.push('-sosv', `"${allConfig.controls.sosvModelPath}"`)
|
||||
this.command.push('-tm', allConfig.controls.transModel)
|
||||
this.command.push('-omn', allConfig.controls.ollamaName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user