Brain Phrye

code cooking diy fiction personal photos politics reviews tools 


[ Listen to article ]

I added a new [ Listen to article ] link to my pages. This is done via the SpeechSynthesis API that I played around with in my little spoken cube toy.

The code to do it is in the speak.js file that each page loads. I’ve broken it out into a gist as I minimize all my js files when I publish.

There are clearly problems with this. Some of them are due to the API, some are due to the fact that I pull the text directly from the article tags.

If I have run-on sentences it will likely fail. The chunking code I used (see the comment at the top of speak.js for link to those gists) handled that better, but it also inserted odd pauses. Breaking it down further on commas for longer sentences would help. However I suspect it would add a certain. Captain. Kirk. quality. to the reading.

Hopefully the API will improve and mature.

It does a terrible job of reading posts with code snippets. And it has a hard time with various bits of jargon. And that’s just what I’ve figured out so far; I assume there will be more bugs based on the text.

Ultimately to fix issues with the text, I’d need to add a way to have my templates generate articles that provide better text to synthesize from.

It’s an interesting start though. It is pretty neat what you can do to make things accessible.