mirror of
https://github.com/HiMeditator/auto-caption.git
synced 2026-02-21 08:34:43 +08:00
fix(engine): 字幕引擎启动路径适配、音频重采样函数适配
This commit is contained in:
@@ -39,15 +39,15 @@ def resample_chunk_mono(chunk: bytes, channels: int, orig_sr: int, target_sr: in
|
|||||||
单通道音频数据块
|
单通道音频数据块
|
||||||
"""
|
"""
|
||||||
if channels == 1:
|
if channels == 1:
|
||||||
chunk_mono = chunk
|
chunk_mono = np.frombuffer(chunk, dtype=np.int16)
|
||||||
|
chunk_mono = chunk_mono.astype(np.float32)
|
||||||
else:
|
else:
|
||||||
# (length * channels,)
|
# (length * channels,)
|
||||||
chunk_np = np.frombuffer(chunk, dtype=np.int16)
|
chunk_np = np.frombuffer(chunk, dtype=np.int16)
|
||||||
# (length, channels)
|
# (length, channels)
|
||||||
chunk_np = chunk_np.reshape(-1, channels)
|
chunk_np = chunk_np.reshape(-1, channels)
|
||||||
# (length,)
|
# (length,)
|
||||||
chunk_mono_f = np.mean(chunk_np.astype(np.float32), axis=1)
|
chunk_mono = np.mean(chunk_np.astype(np.float32), axis=1)
|
||||||
chunk_mono = chunk_mono_f.astype(np.int16)
|
|
||||||
|
|
||||||
ratio = target_sr / orig_sr
|
ratio = target_sr / orig_sr
|
||||||
chunk_mono_r = samplerate.resample(chunk_mono, ratio, converter_type=mode)
|
chunk_mono_r = samplerate.resample(chunk_mono, ratio, converter_type=mode)
|
||||||
@@ -69,6 +69,7 @@ def resample_mono_chunk(chunk: bytes, orig_sr: int, target_sr: int, mode="sinc_b
|
|||||||
单通道音频数据块
|
单通道音频数据块
|
||||||
"""
|
"""
|
||||||
chunk_np = np.frombuffer(chunk, dtype=np.int16)
|
chunk_np = np.frombuffer(chunk, dtype=np.int16)
|
||||||
|
chunk_np = chunk_np.astype(np.float32)
|
||||||
ratio = target_sr / orig_sr
|
ratio = target_sr / orig_sr
|
||||||
chunk_r = samplerate.resample(chunk_np, ratio, converter_type=mode)
|
chunk_r = samplerate.resample(chunk_np, ratio, converter_type=mode)
|
||||||
chunk_r = np.round(chunk_r).astype(np.int16)
|
chunk_r = np.round(chunk_r).astype(np.int16)
|
||||||
|
|||||||
@@ -54,7 +54,12 @@ export class CaptionEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.appPath = path.join(process.resourcesPath, 'engine', 'main.exe')
|
if(process.platform === 'win32') {
|
||||||
|
this.appPath = path.join(process.resourcesPath, 'engine', 'main.exe')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.appPath = path.join(process.resourcesPath, 'engine', 'main')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.command.push('-a', allConfig.controls.audio ? '1' : '0')
|
this.command.push('-a', allConfig.controls.audio ? '1' : '0')
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default {
|
|||||||
"projLink": "Project Link",
|
"projLink": "Project Link",
|
||||||
"manual": "User Manual",
|
"manual": "User Manual",
|
||||||
"engineDoc": "Caption Engine Manual",
|
"engineDoc": "Caption Engine Manual",
|
||||||
"date": "July 29, 2025"
|
"date": "July 30, 2025"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
log: {
|
log: {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default {
|
|||||||
"projLink": "プロジェクトリンク",
|
"projLink": "プロジェクトリンク",
|
||||||
"manual": "ユーザーマニュアル",
|
"manual": "ユーザーマニュアル",
|
||||||
"engineDoc": "字幕エンジンマニュアル",
|
"engineDoc": "字幕エンジンマニュアル",
|
||||||
"date": "2025 年 7 月 29 日"
|
"date": "2025 年 7 月 30 日"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
log: {
|
log: {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default {
|
|||||||
"projLink": "项目链接",
|
"projLink": "项目链接",
|
||||||
"manual": "用户手册",
|
"manual": "用户手册",
|
||||||
"engineDoc": "字幕引擎手册",
|
"engineDoc": "字幕引擎手册",
|
||||||
"date": "2025 年 7 月 29 日"
|
"date": "2025 年 7 月 30 日"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
log: {
|
log: {
|
||||||
|
|||||||
Reference in New Issue
Block a user