0

You can read about Speech Synthesis Web-API [1], [2], is supported to some extent by several browsers [3]

Here is a basic example

let utterance = new SpeechSynthesisUtterance(
  "I want to get this text uttered (on a specific device)"
);
utterance.lang = 'en';
speechSynthesis.speak(utterance);

Is it possible to specify the audio output where it will play?

(it could use a chromium extension if necessary)

Bob
  • 13,867
  • 1
  • 5
  • 27
  • You may want to look at the code for the Chrome extension [AudioPick](https://github.com/rain-fighters/AudioPick) to understand how they do it. – Yogi Oct 14 '22 at 14:03
  • But speech synthesis does add an `audio` or `video` element to the document, so AudioPick won't work. Either way, thank you for trying to help. – Bob Oct 16 '22 at 07:17
  • There's no easy way to achieve what you want as the Web SpeechSynthesis API doesn't provide any facilities to select the output sound device. There's [a discussion](https://github.com/w3c/mediacapture-output/issues/102) on GitHub regarding this issue. Besides, you can also refer to [this thread](https://stackoverflow.com/questions/45003548/how-to-capture-generated-audio-from-window-speechsynthesis-speak-call) and check if the solution works for your situation. – Yu Zhou Oct 17 '22 at 08:30
  • Yes, a streamed version of the solution from the post you mentioned might work for me, since I only need to use this to automate some tests. Not so elegant but good enough :) – Bob Oct 17 '22 at 12:11

0 Answers0