From 86edaaaecc0c14a134d87ca7a39178179f0b5b41 Mon Sep 17 00:00:00 2001 From: Mohammed Elzobair Date: Sat, 8 Mar 2025 14:11:39 +0000 Subject: [PATCH 01/19] feat: add tts support -integrated Web Speech API --- frontend/src/components/MainContent.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/components/MainContent.vue b/frontend/src/components/MainContent.vue index 4d46f0e1..45a96d13 100644 --- a/frontend/src/components/MainContent.vue +++ b/frontend/src/components/MainContent.vue @@ -103,6 +103,21 @@ export default { // Use marked to convert markdown to HTML. return marked(message); }, + + /** + * Uses the Web Speech API to speak the given text. + */ + speakMessage(text) { + if ("speechSynthesis" in window) { + const utterance = new SpeechSynthesisUtterance(text); + // Optional: Configure properties like voice, pitch, rate, and volume. + utterance.lang = "en-US"; // Change if necessary + window.speechSynthesis.speak(utterance); + } else { + console.warn("Speech synthesis is not supported in this browser."); + } + }, + /** * Initializes a new chat with a predefined message. */ From fb0a947a1475dc74f582b44b1ca1471b90d35664 Mon Sep 17 00:00:00 2001 From: Mohammed Elzobair Date: Sat, 8 Mar 2025 14:18:08 +0000 Subject: [PATCH 02/19] feat: add tts support -add tts button --- frontend/src/components/MainContent.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/MainContent.vue b/frontend/src/components/MainContent.vue index 45a96d13..3c2589c3 100644 --- a/frontend/src/components/MainContent.vue +++ b/frontend/src/components/MainContent.vue @@ -43,6 +43,13 @@ {{ getTranslation(currentLanguage, "AI") }} {{ msg.sender }}

+ @@ -117,7 +124,7 @@ export default { console.warn("Speech synthesis is not supported in this browser."); } }, - + /** * Initializes a new chat with a predefined message. */ From 306534b7722ce8e6a079aeeecc66ebc405e1344b Mon Sep 17 00:00:00 2001 From: Mohammed Elzobair Date: Sat, 8 Mar 2025 14:23:11 +0000 Subject: [PATCH 03/19] feat: add tts support -change tts voice to have a British accent --- frontend/src/components/MainContent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/MainContent.vue b/frontend/src/components/MainContent.vue index 3c2589c3..922d58c7 100644 --- a/frontend/src/components/MainContent.vue +++ b/frontend/src/components/MainContent.vue @@ -118,7 +118,7 @@ export default { if ("speechSynthesis" in window) { const utterance = new SpeechSynthesisUtterance(text); // Optional: Configure properties like voice, pitch, rate, and volume. - utterance.lang = "en-US"; // Change if necessary + utterance.lang = "en-UK"; // Change if necessary window.speechSynthesis.speak(utterance); } else { console.warn("Speech synthesis is not supported in this browser."); From 296723dd3cfd93157da5fa5654b79ab689a3d497 Mon Sep 17 00:00:00 2001 From: Mohammed Elzobair Date: Sat, 8 Mar 2025 14:29:11 +0000 Subject: [PATCH 04/19] feat: add tts support -changed icon of tts button --- frontend/public/index.html | 1 + frontend/src/components/MainContent.vue | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/public/index.html b/frontend/public/index.html index 3e5a1396..d31e1c41 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -6,6 +6,7 @@ <%= htmlWebpackPlugin.options.title %> +