2024-07-13 15:44:13 +08:00
|
|
|
import { ipcMain } from 'electron'
|
|
|
|
|
import { DEFINE_STRING } from '../../define/define_string'
|
|
|
|
|
import { LOGGER_DEFINE } from '../../define/logger_define'
|
2024-08-03 12:46:12 +08:00
|
|
|
import { TTS } from '../Service/tts'
|
|
|
|
|
const tts = new TTS()
|
2024-07-13 15:44:13 +08:00
|
|
|
|
|
|
|
|
export function TTSIpc() {
|
|
|
|
|
// 获取当前的TTS配置数据
|
2024-08-12 16:26:08 +08:00
|
|
|
ipcMain.handle(DEFINE_STRING.TTS.GET_TTS_CONFIG, async () => await tts.GetTTSCOnfig())
|
2024-07-13 15:44:13 +08:00
|
|
|
|
|
|
|
|
// 保存TTS配置
|
2024-08-12 16:26:08 +08:00
|
|
|
ipcMain.handle(
|
|
|
|
|
DEFINE_STRING.TTS.SAVE_TTS_CONFIG,
|
|
|
|
|
async (event, data) => await tts.SaveTTSConfig(data)
|
|
|
|
|
)
|
2024-08-03 12:46:12 +08:00
|
|
|
|
|
|
|
|
// 生成音频
|
2024-08-12 16:26:08 +08:00
|
|
|
ipcMain.handle(
|
|
|
|
|
DEFINE_STRING.TTS.GENERATE_AUDIO,
|
|
|
|
|
async (event, text) => await tts.GenerateAudio(text)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 生成SRT字幕文件
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
DEFINE_STRING.TTS.GENERATE_SRT,
|
|
|
|
|
async (event, ttsId) => await tts.GenerateSRT(ttsId)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 删除配音历史记录
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
DEFINE_STRING.TTS.DELETE_TTS_HISTORY,
|
|
|
|
|
async (event, ttsId) => await tts.DeleteTTSHistory(ttsId)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 获取配音的历史记录
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
DEFINE_STRING.TTS.GET_TTS_HISTORY_DATA,
|
|
|
|
|
async (event, queryCondition) => await tts.GetTTSHistoryData(queryCondition)
|
|
|
|
|
)
|
2024-07-13 15:44:13 +08:00
|
|
|
}
|