feat: support Edge browser

This commit is contained in:
n4ze3m
2025-02-08 23:06:09 +05:30
parent 87c2024771
commit ef51cf85ff
10 changed files with 114 additions and 192 deletions

View File

@@ -32,7 +32,10 @@ export const useTTS = () => {
if (isSSML) {
utterance = markdownToSSML(utterance)
}
if (import.meta.env.BROWSER === "chrome") {
if (
import.meta.env.BROWSER === "chrome" ||
import.meta.env.BROWSER === "edge"
) {
chrome.tts.speak(utterance, {
voiceName: voice,
onEvent(event) {
@@ -68,7 +71,7 @@ export const useTTS = () => {
let currentAudioData =
nextAudioData ||
(await generateSpeech(apiKey, sentences[i], voiceId, modelId))
if (i < sentences.length - 1) {
generateSpeech(apiKey, sentences[i + 1], voiceId, modelId)
.then((nextAudioData) => {
@@ -112,7 +115,7 @@ export const useTTS = () => {
return
}
if (import.meta.env.BROWSER === "chrome") {
if (import.meta.env.BROWSER === "chrome" || import.meta.env.BROWSER === "edge") {
chrome.tts.stop()
} else {
window.speechSynthesis.cancel()