fix: catch setTTS execption

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-24 16:53:25 +08:00
parent 83b4031405
commit f7afd373de
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
3 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,8 @@ import fs from "node:fs"
import { createRequire } from "node:module"
import path from "node:path"
import { app } from "electron"
import { callGlobalContextMethod } from "@follow/shared/bridge"
import { app, BrowserWindow } from "electron"
import { MsEdgeTTS, OUTPUT_FORMAT } from "msedge-tts"
import { readability } from "../lib/readability"
@ -49,8 +50,20 @@ export const readerRoute = {
return voices
}),
setVoice: t.procedure.input<string>().action(async ({ input }) => {
await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS)
setVoice: t.procedure.input<string>().action(async ({ input, context: { sender } }) => {
const window = BrowserWindow.fromWebContents(sender)
if (!window) {
return
}
await tts.setMetadata(input, OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS).catch((error) => {
callGlobalContextMethod(window, "toast.error", [
error.message,
{
duration: 1000,
},
])
})
}),
detectCodeStringLanguage: t.procedure

View File

@ -14,6 +14,8 @@ const ERROR_PATTERNS = [
"Unable to open cursor",
"Document is not focused.",
"HTTP Client Error",
// Biz errors
"Chain aborted",
]
export const SentryConfig: BrowserOptions = {

View File

@ -192,7 +192,7 @@ export const VoiceSelector = () => {
<SelectTrigger size="sm" className="w-48">
<SelectValue />
</SelectTrigger>
<SelectContent className="h-64">
<SelectContent position="item-aligned">
{data?.map((item) => (
<SelectItem key={item.ShortName} value={item.ShortName}>
{item.FriendlyName}