function processTranscription(text) { updateStatus("Processing..."); const selectedLanguage = document.getElementById('language-select').value; // Log the data being sent to the backend console.log("Sending data to backend:", { text: text, targetLanguage: selectedLanguage }); // Send transcription and language to the backend for translation fetch('/translate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: text, targetLanguage: selectedLanguage }) }) .then(response => response.json()) .then(data => { updateOutput(data.translatedText); // Display translated text speakText(data.translatedText); // Speak the translated text updateStatus("Done processing."); }) .catch(error => { console.error('Error:', error); // Log the error updateStatus("Error processing."); }); } } window.speechSynthesis.speak(speech); } document.getElementById('language-count').innerText = 6; // Set language count