1

Is there any possible solution to get mp3 of text I get blob but not play able

text =  document.getElementById("text");
            voice = document.getElementById("Svoice");
            action = document.getElementById("action");

        function texttospeech(text){
            let speech = new SpeechSynthesisUtterance(text);
            items = [];
            let record = speechSynthesis.speak(speech);
            
            items.push(record);
            var blob = new Blob(items, {type:'audio/mp3'});
            aud.src = URL.createObjectURL(blob);
        }

        action.addEventListener('click', e => {
            e.preventDefault();
            if (text.value !== ""){
                texttospeech(text.value);
            }
        });

Can anyone help me without node.js or any other library only javascript please

Mudassar
  • 11
  • 3

1 Answers1

1

TL;DR:

You can't record speech synthesis output in the browser.


The W3C draft report for the Web Speech API does not include methods for accessing speech synthesis output, and SpeechSynthesis.speak(speech) returns undefined, not data to create a blob from.

Browser software implementing the speech synthesizer component of the API may in fact be calling the O/S to synthesize the speech rather than producing any kind of audio stream itself.

Most speech synthesis output heard on YouTube is likely being captured by the video recording/screen capture software used to record the video. Please research further to determine what might suite you best - I am not offering recommendations other than to include "Xbox Gamebar App" and "VLC" in your searches if they don't turn up by themselves.

This related question answer covers interesting information about copyright and potential limitations on commercial use of recorded speech synthesis output imposed by some manufacturers.

traktor
  • 17,588
  • 4
  • 32
  • 53
  • You're welcome. Please take the [site tour](https://stackoverflow.com/tour) - you even get a badge. Although you hoped to be able to record speech synthesis in a browser, accepting this answer will close off the post for people or bots searching for unsolved questions. – traktor Apr 20 '22 at 23:16