diff --git a/engine/audio2text/sosv.py b/engine/audio2text/sosv.py index 28e38e3..666b0b1 100644 --- a/engine/audio2text/sosv.py +++ b/engine/audio2text/sosv.py @@ -63,7 +63,7 @@ class SosvRecognizer: vad_config.silero_vad.threshold = 0.5 vad_config.silero_vad.min_silence_duration = 0.1 vad_config.silero_vad.min_speech_duration = 0.25 - vad_config.silero_vad.max_speech_duration = 8 + vad_config.silero_vad.max_speech_duration = 5 vad_config.sample_rate = 16000 self.window_size = vad_config.silero_vad.window_size self.vad = sherpa_onnx.VoiceActivityDetector(vad_config, buffer_size_in_seconds=100) diff --git a/engine/main.py b/engine/main.py index a99ca44..fba4845 100644 --- a/engine/main.py +++ b/engine/main.py @@ -17,8 +17,11 @@ def audio_recording(stream: AudioStream, resample: bool, record = False, path = wf = None full_name = '' if record: - if path != '' and path[-1] != '/': - path += '/' + if path != '': + if path.startswith('"') and path.endswith('"'): + path = path[1:-1] + if path[-1] != '/': + path += '/' cur_dt = datetime.datetime.now() name = cur_dt.strftime("audio-%Y-%m-%dT%H-%M-%S") full_name = f'{path}{name}.wav' diff --git a/src/main/types/index.ts b/src/main/types/index.ts index d80f142..4fe5db2 100644 --- a/src/main/types/index.ts +++ b/src/main/types/index.ts @@ -23,6 +23,7 @@ export interface Controls { } export interface Styles { + lineNumber: number, lineBreak: number, fontFamily: string, fontSize: number, diff --git a/src/main/utils/AllConfig.ts b/src/main/utils/AllConfig.ts index 9e6109a..5a7ea8c 100644 --- a/src/main/utils/AllConfig.ts +++ b/src/main/utils/AllConfig.ts @@ -19,6 +19,7 @@ function getDesktopPath() { } const defaultStyles: Styles = { + lineNumber: 1, lineBreak: 1, fontFamily: 'sans-serif', fontSize: 24, diff --git a/src/main/utils/CaptionEngine.ts b/src/main/utils/CaptionEngine.ts index 1b876ff..c87e383 100644 --- a/src/main/utils/CaptionEngine.ts +++ b/src/main/utils/CaptionEngine.ts @@ -66,7 +66,7 @@ export class CaptionEngine { 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.command.push('-rp', `"${allConfig.controls.recordingPath}"`) } this.port = Math.floor(Math.random() * (65535 - 1024 + 1)) + 1024 this.command.push('-p', this.port.toString()) diff --git a/src/renderer/src/components/CaptionStyle.vue b/src/renderer/src/components/CaptionStyle.vue index c3498c7..4a2211d 100644 --- a/src/renderer/src/components/CaptionStyle.vue +++ b/src/renderer/src/components/CaptionStyle.vue @@ -6,6 +6,16 @@ {{ $t('style.resetStyle') }} +
+ {{ '字幕行数' }} + + 1 + 2 + 3 + 4 + +
+
{{ $t('style.longCaption') }} -

- {{ captionData[captionData.length-1].text }} - {{ $t('example.original') }} -

-

- {{ captionData[captionData.length-1].translation }} - {{ $t('example.translation') }} -

+ +
@@ -212,6 +251,14 @@ import { storeToRefs } from 'pinia' import { notification } from 'ant-design-vue' import { useI18n } from 'vue-i18n' import { useCaptionLogStore } from '@renderer/stores/captionLog'; + +const revArr = { + 1: [1], + 2: [2, 1], + 3: [3, 2, 1], + 4: [4, 3, 2, 1], +} + const captionLog = useCaptionLogStore(); const { captionData } = storeToRefs(captionLog); @@ -220,6 +267,7 @@ const { t } = useI18n() const captionStyle = useCaptionStyleStore() const { changeSignal } = storeToRefs(captionStyle) +const currentLineNumber = ref(1) const currentLineBreak = ref(0) const currentFontFamily = ref('sans-serif') const currentFontSize = ref(24) @@ -253,6 +301,7 @@ function useSameStyle(){ } function applyStyle(){ + captionStyle.lineNumber = currentLineNumber.value; captionStyle.lineBreak = currentLineBreak.value; captionStyle.fontFamily = currentFontFamily.value; captionStyle.fontSize = currentFontSize.value; @@ -282,6 +331,7 @@ function applyStyle(){ } function backStyle(){ + currentLineNumber.value = captionStyle.lineNumber; currentLineBreak.value = captionStyle.lineBreak; currentFontFamily.value = captionStyle.fontFamily; currentFontSize.value = captionStyle.fontSize; diff --git a/src/renderer/src/stores/captionStyle.ts b/src/renderer/src/stores/captionStyle.ts index ece760c..5cc3959 100644 --- a/src/renderer/src/stores/captionStyle.ts +++ b/src/renderer/src/stores/captionStyle.ts @@ -4,6 +4,7 @@ import { Styles } from '@renderer/types' import { breakOptions } from '@renderer/i18n' export const useCaptionStyleStore = defineStore('captionStyle', () => { + const lineNumber = ref(1) const lineBreak = ref(1) const fontFamily = ref('sans-serif') const fontSize = ref(24) @@ -38,6 +39,7 @@ export const useCaptionStyleStore = defineStore('captionStyle', () => { function sendStylesChange() { const styles: Styles = { + lineNumber: lineNumber.value, lineBreak: lineBreak.value, fontFamily: fontFamily.value, fontSize: fontSize.value, @@ -65,6 +67,7 @@ export const useCaptionStyleStore = defineStore('captionStyle', () => { } function setStyles(args: Styles){ + lineNumber.value = args.lineNumber lineBreak.value = args.lineBreak fontFamily.value = args.fontFamily fontSize.value = args.fontSize @@ -91,6 +94,7 @@ export const useCaptionStyleStore = defineStore('captionStyle', () => { }) return { + lineNumber, // 显示字幕行数 lineBreak, // 换行方式 fontFamily, // 字体族 fontSize, // 字体大小 diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index d80f142..4fe5db2 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -23,6 +23,7 @@ export interface Controls { } export interface Styles { + lineNumber: number, lineBreak: number, fontFamily: string, fontSize: number, diff --git a/src/renderer/src/views/CaptionPage.vue b/src/renderer/src/views/CaptionPage.vue index 69da4ae..b2b3b66 100644 --- a/src/renderer/src/views/CaptionPage.vue +++ b/src/renderer/src/views/CaptionPage.vue @@ -12,26 +12,53 @@ textShadow: captionStyle.textShadow ? `${captionStyle.offsetX}px ${captionStyle.offsetY}px ${captionStyle.blur}px ${captionStyle.textShadowColor}` : 'none' }" > -

- {{ captionData[captionData.length-1].text }} - {{ $t('example.original') }} -

-

- {{ captionData[captionData.length-1].translation }} - {{ $t('example.translation') }} -

+ +
@@ -56,6 +83,14 @@ import { ref, onMounted } from 'vue'; import { useCaptionStyleStore } from '@renderer/stores/captionStyle'; import { useCaptionLogStore } from '@renderer/stores/captionLog'; import { storeToRefs } from 'pinia'; + +const revArr = { + 1: [1], + 2: [2, 1], + 3: [3, 2, 1], + 4: [4, 3, 2, 1], +} + const captionStyle = useCaptionStyleStore(); const captionLog = useCaptionLogStore(); const { captionData } = storeToRefs(captionLog);