Skip to content

Commit

Permalink
fix: catch setTTS execption
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 24, 2024
1 parent 83b4031 commit f7afd37
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
19 changes: 16 additions & 3 deletions apps/main/src/tipc/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions apps/renderer/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion apps/renderer/src/modules/settings/tabs/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit f7afd37

Please sign in to comment.