diff --git a/src/js/main.js b/src/js/main.js index 3de3d08..e9cdbac 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -271,39 +271,38 @@ window.speak = (text) => { async function speak(text) { addToConversationHistory(text, 'dark') - fetch("/api/detectLanguage?text="+text, { - method: "POST" - }) - .then(response => response.text()) - .then(async language => { - console.log(`Detected language: ${language}`); - - const generatedResult = await generateText(text); + //fetch("/api/detectLanguage?text="+text, { + // method: "POST" + //}) + //.then(response => response.text()) + //.then(async language => { + //console.log(`Detected language: ${language}`); + language = 'ar-AE' + const generatedResult = await generateText(text); - let spokenTextssml = `${generatedResult}` + let spokenTextssml = `${generatedResult}` - if (language == 'ar-AE') { - spokenTextssml = `${generatedResult}` - } - let spokenText = generatedResult - speechSynthesizer.speakSsmlAsync(spokenTextssml, (result) => { - if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) { - console.log("Speech synthesized to speaker for text [ " + spokenText + " ]. Result ID: " + result.resultId) - } else { - console.log("Unable to speak text. Result ID: " + result.resultId) - if (result.reason === SpeechSDK.ResultReason.Canceled) { - let cancellationDetails = SpeechSDK.CancellationDetails.fromResult(result) - console.log(cancellationDetails.reason) - if (cancellationDetails.reason === SpeechSDK.CancellationReason.Error) { - console.log(cancellationDetails.errorDetails) - } - } + if (language == 'ar-AE') { + spokenTextssml = `${generatedResult}` + } + let spokenText = generatedResult + speechSynthesizer.speakSsmlAsync(spokenTextssml, (result) => { + if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) { + console.log("Speech synthesized to speaker for text [ " + spokenText + " ]. Result ID: " + result.resultId) + } else { + console.log("Unable to speak text. Result ID: " + result.resultId) + if (result.reason === SpeechSDK.ResultReason.Canceled) { + let cancellationDetails = SpeechSDK.CancellationDetails.fromResult(result) + console.log(cancellationDetails.reason) + if (cancellationDetails.reason === SpeechSDK.CancellationReason.Error) { + console.log(cancellationDetails.errorDetails) } - }) - }) - .catch(error => { - console.error('Error:', error); - }); + } + } + }) + .catch(error => { + console.error('Error:', error); + }); } speak(text); }