feat: add option to remove reasoning tag from TTS output
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user