From 0f9c788aa45b70d4fdfdab07d8810af575238026 Mon Sep 17 00:00:00 2001 From: an-lee Date: Sun, 17 Mar 2024 10:56:20 +0800 Subject: [PATCH] add more logs for echogarden --- enjoy/src/main/echogarden.ts | 17 ++++++++++++++--- enjoy/src/renderer/hooks/use-transcriptions.tsx | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/enjoy/src/main/echogarden.ts b/enjoy/src/main/echogarden.ts index a386bca8..1b15af67 100644 --- a/enjoy/src/main/echogarden.ts +++ b/enjoy/src/main/echogarden.ts @@ -9,7 +9,10 @@ import settings from "@main/settings"; import fs from "fs-extra"; import ffmpegPath from "ffmpeg-static"; -Echogarden.setGlobalOption("ffmpegPath", ffmpegPath.replace("app.asar", "app.asar.unpacked")); +Echogarden.setGlobalOption( + "ffmpegPath", + ffmpegPath.replace("app.asar", "app.asar.unpacked") +); const __filename = url.fileURLToPath(import.meta.url); /* @@ -53,12 +56,20 @@ class EchogardenWrapper { ipcMain.handle( "echogarden-align", async ( - _event, + event, input: AudioSourceParam, transcript: string, options: AlignmentOptions ) => { - return this.align(input, transcript, options); + try { + return await this.align(input, transcript, options); + } catch (err) { + logger.error(err); + event.sender.send("on-notification", { + type: "error", + message: err.message, + }); + } } ); diff --git a/enjoy/src/renderer/hooks/use-transcriptions.tsx b/enjoy/src/renderer/hooks/use-transcriptions.tsx index 929cf18b..2698c464 100644 --- a/enjoy/src/renderer/hooks/use-transcriptions.tsx +++ b/enjoy/src/renderer/hooks/use-transcriptions.tsx @@ -8,6 +8,7 @@ import { import { toast } from "@renderer/components/ui"; import { TimelineEntry } from "echogarden/dist/utilities/Timeline.d.js"; import { MAGIC_TOKEN_REGEX, END_OF_SENTENCE_REGEX } from "@/constants"; +import { t } from "i18next"; export const useTranscriptions = (media: AudioType | VideoType) => { const { whisperConfig } = useContext(AISettingsProviderContext); @@ -73,6 +74,8 @@ export const useTranscriptions = (media: AudioType | VideoType) => { }); } }); + } else { + throw new Error(t("forceAlignmentFailed")); } /* @@ -87,7 +90,6 @@ export const useTranscriptions = (media: AudioType | VideoType) => { .match(END_OF_SENTENCE_REGEX) && nextSentence?.text ) { - console.log(sentence.text); nextSentence.text = [sentence.text, nextSentence.text].join(" "); nextSentence.timeline = [ ...sentence.timeline,