unclutter icon indicating copy to clipboard operation
unclutter copied to clipboard

feat: add tts support

Open ElijahPepe opened this issue 2 years ago • 5 comments

This PR adds in TTS support via the Web Speech API. TTS is handled via a button on the side of the article. Upon enabling TTS, the article's contents are grabbed and then piped into the Web Speech API, prefixed by "From" and then the hostname of the article; likewise, clicking the button again will cancel the current TTS operation.

Resolves: #11

ElijahPepe avatar Jun 05 '22 04:06 ElijahPepe

Hey @ElijahPepe again thank you very much for the PR and the idea!

I haven't forgotten about this and #21, just wanted to ship some unclutter reliability improvements before adding more features (which also then avoids speaking-out things like "share button").

Do you know of a way to improve the voice quality of the Web Speech API? Maybe some relatively inexpensive API to plug into it?

phgn0 avatar Jun 16 '22 12:06 phgn0

Unfortunately, without detecting the voices the user has, there's no way to improve the voice quality. The API works by plugging into the user's TTS voices for their operating system, which most will have.

ElijahPepe avatar Jun 16 '22 14:06 ElijahPepe

@phgn0 I'd like to open this back up. If native TTS via the OS isn't possible, then we should look into alternatives. Google Cloud looks like a great option, but costly, and depends on an API key.

ElijahPepe avatar Jul 16 '22 19:07 ElijahPepe

@ElijahPepe You're right, probably it makes sense to start with the OS TTS. We can always add the GCP TTS as another SpeechSynthesis implementation later. Thank you for the reminder!

It would also be cool to highlight the spoken words via SpeechSynthesisUtterance#events like in the Firefox reader mode -- that's yet another future improvement :)

I converted the UI overlay code to Svelte in the past weeks, do you want to rebase the PR or should I take a look?

phgn0 avatar Jul 20 '22 06:07 phgn0

I'll have you take a look, I'm pretty busy this week. If I get to it, I'll revise this PR.

ElijahPepe avatar Jul 20 '22 14:07 ElijahPepe