Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
After some time testing voice games in my Alexa device, one question came to my mindâŠ
Why not try to convert a classic game control system to a Voice User Inteface?
So letâs do a simple experiment with a Space Invaders written in Javascript.
After some walkarounds I made a requirement list in order to reach my target:
- Speech Recognition
- Speech Synthesis
- An NLU or set of hardcode rules to match my utterances to intents
- Implementation of the web reactions to these intents
Well, once I had more or less clear what I was looking for, I use the second engineer lesson: donât reinvent the wheel. So, once again I whispered something to Google and it led me to something called Woice.
Once I went through the tutorial for creating a new application, I charged the SDK script on my HTML and draw a few lines of code over the space invaders control system.
These lines can be explained in three concepts: Handler, Instance and Speech Recognition Trigger.
The first concept is the Handler which is composed by 2 functions: canHandle, which dictates if the code of the second function handle should be executed or not.
I know, itâs easier if we have some tangible:
The code above goes as simple as this: when we match the intent âmoveRightâ in the Dialogflow agent (this is Woiceâs supported NLU), we trigger GlobalActionState.RIGHT =Â true.
The second concept is the instance, once we have defined our handlers we are going to build a Woice instance with these.
And the last one, we are going to attach a Speech Recognition Trigger. In this case, we associate this event to the control+B keyboard combination.
And the final and editable result are:
Space Invaders - Woice Annotated code
Itâs definitely not the best use case (gaming requires real-time action, so itâs not really suited for voice) but, in the other hand, I played more time that I would like to admit.
If you have any question, review, or simply a project you want to share with me Iâm glad to hear from you :).
Playing Space Invaders With Your Own Voice was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.