3 mins read
|
18 Feb 2021

The Power Of Code

I’m writing this in a day surgery ward in London, waiting for my operation. I’ve been here before. Two months ago in fact. I’m back in for the same procedure - removal of cancerous tissue on the top of my tongue. The analysis from last time revealed they didn’t take enough. I’m not a smoker or a heavy drinker, just the victim of bad luck.

It’s horrible to be back here, especially during a pandemic, but this time I know what to expect. Last time I couldn’t talk for two weeks. After a while my speech got better but a few words still evaded me.

Whilst struggling to communicate I found a text-to-speech app which really helped me get over some of the frustrations. A few days ago I was getting anxious about the operation and wanted to get lost in a project, so I created Mouth-Piece! It’s a very MVP which allows me to prerecord some voice expressions plus the ability to perform text-to-speech. I created it as a PWA using Stencil and Ionic 5.

With no previous Stencil experience this seemed like a good way to get lost in my work and to learn something useful. It all went surprisingly well and I was amazed at how simple it was to add the Web API interfaces:

SpeechSynthesisUtterance

var synth = window.speechSynthesis let utterThis = new SpeechSynthesisUtterance('Hello world!') synth.speak(utterThis)

MediaRecorder

navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => { var mediaRecorder = new MediaRecorder(stream) mediaRecorder.ondataavailable = (e) => { //This returns the audio data as a Blob console.log(e.data) } mediaRecorder.start() })

It took about three days in total to create - one of which was spent reading the Stencil documentation and pulling apart the demos. There’s lots of problems with it (like why does it take so long to start?!) and the code isn’t super clean. But it works and can be installed as a WebApp on my phone.

Mouth-Piece!

mouth piece screenshot

mouth piece screenshot

So as I’m sitting here in my compression socks (and not a lot else!) I’ve been reflecting on the Power Of Code and what I was able to create in three days. This WebApp is going to be vital for me over the next two weeks. I’ve recorded myself calling my dog, telling my fiancée that I love her and, most importantly, I’ve recorded myself asking for more pain meds! I also recorded some voice commands as that’s how a lot of my lights are controlled! Combined with the text-to-speech ability this app is going to be my crutch during recovery.

I’m always amazed at the powerful life improving things we can create as developers. Whether it’s improving your sleep, helping you meditate, reminding you to take medication, help with exercise or to reduce anxiety. There are some great life changing apps out there!

So these are my thoughts on the Power of Code before I go under the knife! I’d be really interested to hear some of yours!

Speak to you later… Or maybe my app will!

Loading...

- Resources

Web API
SpeechSynthesisUtterance
MediaRecorder
Google Web Recording Audio
Mouth-Piece!