feat: add option to remove reasoning tag from TTS output

This commit is contained in:
n4ze3m
2025-02-09 13:00:04 +05:30
parent 023d3c2fb2
commit 084b859e3e
21 changed files with 106 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import {
getElevenLabsApiKey,
getElevenLabsModel,
getElevenLabsVoiceId,
getRemoveReasoningTagTTS,
getTTSProvider,
getVoice,
isSSMLEnabled
@@ -11,6 +12,7 @@ import {
import { markdownToSSML } from "@/utils/markdown-to-ssml"
import { generateSpeech } from "@/services/elevenlabs"
import { splitMessageContent } from "@/utils/tts"
import { removeReasoning } from "@/libs/reasoning"
export interface VoiceOptions {
utterance: string
@@ -26,6 +28,11 @@ export const useTTS = () => {
try {
const voice = await getVoice()
const provider = await getTTSProvider()
const isRemoveReasoning = await getRemoveReasoningTagTTS()
if (isRemoveReasoning) {
utterance = removeReasoning(utterance)
}
if (provider === "browser") {
const isSSML = await isSSMLEnabled()
@@ -115,7 +122,10 @@ export const useTTS = () => {
return
}
if (import.meta.env.BROWSER === "chrome" || import.meta.env.BROWSER === "edge") {
if (
import.meta.env.BROWSER === "chrome" ||
import.meta.env.BROWSER === "edge"
) {
chrome.tts.stop()
} else {
window.speechSynthesis.cancel()