feat(translation): 添加非实时翻译功能用户界面组件

This commit is contained in:
himeditator
2025-09-04 23:41:22 +08:00
parent 14987cbfc5
commit 2b7ce06f04
15 changed files with 193 additions and 77 deletions

View File

@@ -6,6 +6,8 @@ export interface Controls {
engineEnabled: boolean,
sourceLang: string,
targetLang: string,
transModel: string,
ollamaName: string,
engine: string,
audio: 0 | 1,
translation: boolean,
@@ -46,11 +48,6 @@ export interface CaptionItem {
translation: string
}
export interface CaptionTranslation {
time_s: string,
translation: string
}
export interface SoftwareLogItem {
type: "INFO" | "WARN" | "ERROR",
index: number,

View File

@@ -1,13 +1,17 @@
import {
UILanguage, UITheme, Styles, Controls,
CaptionItem, CaptionTranslation,
FullConfig, SoftwareLogItem
CaptionItem, FullConfig, SoftwareLogItem
} from '../types'
import { Log } from './Log'
import { app, BrowserWindow } from 'electron'
import * as path from 'path'
import * as fs from 'fs'
interface CaptionTranslation {
time_s: string,
translation: string
}
const defaultStyles: Styles = {
lineBreak: 1,
fontFamily: 'sans-serif',
@@ -32,6 +36,8 @@ const defaultStyles: Styles = {
const defaultControls: Controls = {
sourceLang: 'en',
targetLang: 'zh',
transModel: 'ollama',
ollamaName: '',
engine: 'gummy',
audio: 0,
engineEnabled: false,

View File

@@ -81,7 +81,9 @@ export class CaptionEngine {
}
else if(allConfig.controls.engine === 'vosk'){
this.command.push('-e', 'vosk')
this.command.push('-m', `"${allConfig.controls.modelPath}"`)
this.command.push('-m', `"${allConfig.controls.modelPath}"`)
this.command.push('-tm', allConfig.controls.transModel)
this.command.push('-on', allConfig.controls.ollamaName)
}
}
Log.info('Engine Path:', this.appPath)
@@ -257,6 +259,9 @@ function handleEngineData(data: any) {
else if(data.command === 'info') {
Log.info('Engine Info:', data.content)
}
else if(data.command === 'warn') {
Log.warn('Engine Warn:', data.content)
}
else if(data.command === 'error') {
Log.error('Engine Error:', data.content)
controlWindow.sendErrorMessage(/*i18n('engine.error') +*/ data.content)