Refactor whisper notification (#1003)

* update notification when whisper failed

* fix style
This commit is contained in:
an-lee
2024-08-21 15:05:39 +08:00
committed by GitHub
parent 744b8fcc1c
commit 2ab84fc067
6 changed files with 20 additions and 10 deletions

View File

@@ -411,6 +411,7 @@
"pleaseDownloadWhisperModelFirst": "Please download whisper model first",
"whisperIsWorkingGood": "Whisper is working good",
"whisperIsNotWorking": "Whisper is not working",
"whisperTranscribeFailed": "Whisper transcribe failed. Maybe your machine is not compatbile with it. Please use other STT service. {{error}}",
"checkingWhisperModel": "Checking whisper model",
"whisperModelIsWorkingGood": "Whisper model is working good",
"whisperModelIsNotWorking": "Whisper model is not working",

View File

@@ -411,6 +411,7 @@
"pleaseDownloadWhisperModelFirst": "请先下载 Whisper 模型",
"whisperIsWorkingGood": "Whisper 正常工作",
"whisperIsNotWorking": "Whisper 无法正常工作,请尝试更换模型后重试,或联系开发者",
"whisperTranscribeFailed": "Whisper 语音转文本失败。您的设备可能不兼容该功能,请选择其他语音转文本服务。{{error}}",
"checkingWhisperModel": "正在检查 Whisper 模型",
"whisperModelIsWorkingGood": "Whisper 模型正常工作",
"whisperModelIsNotWorking": "Whisper 模型无法正常工作,请尝试更换模型后重试,或联系开发者",

View File

@@ -7,6 +7,7 @@ import fs from "fs-extra";
import log from "@main/logger";
import url from "url";
import { enjoyUrlToPath } from "./utils";
import { t } from "i18next";
const __filename = url.fileURLToPath(import.meta.url);
/*
@@ -299,12 +300,19 @@ class Whipser {
});
ipcMain.handle("whisper-transcribe", async (event, params, options) => {
return await this.transcribe(params, {
return this.transcribe(params, {
...options,
onProgress: (progress) => {
event.sender.send("whisper-on-progress", progress);
},
});
})
.then((result) => {
return result;
})
.catch((err) => {
logger.error(err);
throw t("whisperTranscribeFailed", { error: err.message });
});
});
ipcMain.handle("whisper-abort", async (_event) => {

View File

@@ -96,12 +96,10 @@ export const AudiosTable = (props: {
{dayjs(audio.createdAt).format("YYYY-MM-DD HH:mm")}
</TableCell>
<TableCell>
{audio.transcribing ? (
<PingPoint colorClassName="bg-yellow-500" />
) : audio.transcribed ? (
{audio.transcribed ? (
<CheckCircleIcon className="text-green-500 w-4 h-4" />
) : (
<PingPoint colorClassName="bg-gray-500" />
<PingPoint colorClassName="bg-gray-500" className="w-2 h-2" />
)}
</TableCell>
<TableCell>

View File

@@ -96,12 +96,10 @@ export const VideosTable = (props: {
{dayjs(video.createdAt).format("YYYY-MM-DD HH:mm")}
</TableCell>
<TableCell>
{video.transcribing ? (
<PingPoint colorClassName="bg-yellow-500" />
) : video.transcribed ? (
{video.transcribed ? (
<CheckCircleIcon className="text-green-500 w-4 h-4" />
) : (
<PingPoint colorClassName="bg-gray-500" />
<PingPoint colorClassName="bg-gray-500" className="w-2 h-2" />
)}
</TableCell>
<TableCell>

View File

@@ -222,6 +222,10 @@ export const useTranscribe = () => {
}
);
if (!res) {
throw new Error(t("whisperTranscribeFailed", { error: "" }));
}
const timeline: TimelineEntry[] = res.transcription
.map((segment) => {
// ignore the word if it is empty or in the format of `[xxx]` or `(xxx)`