I’m using the "SpeechSynthesisUtterance" to generate sound from text, I wonder if it is possible to connect "AnalyserNode" to the output audio stream, so I can create voice viz to the output of the text to speech web API in javascript or typescript.
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Thanks @chrisguttandin I've created something like this:
but the stream is empty, any advice, what is exactly the straem is returning here? My goal is to capture the sound is going out from the speakers. I don' want to use MediaDevices.getDisplayMedia()
Unfortunately there is no easy way to do this.
The only possible workaround right now would be to record the audio of the current tab with
getDisplayMedia()
but that requires a user interaction and you have to rely on the user to pick the correct tab.There was once a meanwhile closed issue for the Web Audio API to enable this.
There are still two open issues on the Web Speech API repo about this problem. They are about getting the synthesized speech as audio data or as a MediaStreamTrack. Maybe it’s a good idea to add your use case to one of those issues. It’s hopefully resuming the discussion.