Re:Free Text-to-Speech App with natural voices
by pogue on Friday August 23, 2024 @03:25PM
(#41332228)
I saved this to pastebin (mostly to see the syntax). Does this require Voicegen to be installed or how's it working?
https://pastebin.com/zuRVpiVh
Re:Free Text-to-Speech App with natural voices
by ortsa on Friday August 23, 2024 @03:36PM
(#41332320)
I believe it's using the web speech API https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_...
I've played with it a bit (I made a local nonsense social media thing, reading llm content), and its surprisingly easy to get text to display in sync with the audio. It works with voices that are installed on the users system.
Also, this bookmarklet will speak highlighted text in the browser regardless of platform:
javascript:void function(){ javascript:(function(){ var selection = window.getSelection().toString(); if (!selection) { alert("Please select some text on the page."); return; } var encodedSelection = document.createElement("div"); encodedSelection.textContent = selection; var processedContent = encodedSelection.innerHTML.replace(/\n/g, " <br></br> "); var words = processedContent.split(" "); var formattedText = ""; var speechContent = ""; for (var i = 0; i < words.length; i++) { var word = words[i]; var chunkSize = Math.floor(word.length / 3) + 1; var boldPart = "<span style='font-weight:bolder'>" + word.substring(0, chunkSize) + "</span>"; var lightPart = "<span style='font-weight:lighter'>" + word.substring(chunkSize, word.length) + "</span>"; var formattedWord = boldPart + lightPart; if (word.endsWith(".")) { formattedWord += "<span style='color:red'> *</span>"; } formattedText += formattedWord + " "; speechContent += word + " "; } var newWindow = window.open("", "_blank"); newWindow.document.write("<html><head><title>Spoken Content</title></head><body><input type='range' min='0.1' max='10' value='1' step='0.1' id='rate-slider'><p id='content' style='background-color:#EDD1B0;font-size:40;line-height:200%25;font-family:Arial'>"%20+%20formattedText%20+%20"</p></body></html>");%20var%20rateSlider%20=%20newWindow.document.getElementById("rate-slider");%20var%20utterance%20=%20new%20SpeechSynthesisUtterance(speechContent);%20rateSlider.addEventListener("input",%20function()%20{%20utterance.rate%20=%20rateSlider.value;%20window.speechSynthesis.cancel();%20window.speechSynthesis.speak(utterance);%20});%20window.speechSynthesis.speak(utterance);%20})();}();