123
user profile image

This pen shows how the speech recognition API can be used to retrieve a spoken word from a user and perform an action (e.g. locking/unlocking a padlock) if that word is valid (chrome only).

Padlock design inspired by Chris Cacioppe on Dribbble

Comments

  1. this gave me so much idea IRL! We are currently developing a website for a clinic, and this will make the site more accessible for some users! Nice demo!

  2. This is insane mate, absolutely love it!

  3. Unlock - oh, cool! lack lok sack - fuuuu

  4. Do you know why it breaks the animation when the keyword is modified?

  5. @dxp1

    I think I understand what you're asking:

    if (transcript === 'unlock' && !padlock.classList.contains('unlock')) {
        openPadlock();
    } else {
        if (transcript === 'lock' && padlock.classList.contains('unlock')) {
            closePadlock();
        }
    }
    

    You can change what the transcript is checking for by changing the transcript === 'unlock' and transcript === 'lock' values to whatever string you want to check for and it should still work. If you also want to change the class name to something else, you will also have to change both references in this condition e.g. padlock.classList.contains('unlock'), in the openPadlock and closePadlock functions on lines 15 and 19 e.g. padlock.classList.add('unlock'), and in the CSS at lines 68 and 72 e.g. .padlock.unlock::before

  6. Ah! the CSS was the culprit! thank you very helpful and amazing work!

Leave a Comment Markdown supported. Click @usernames to add to comment.

You must be logged in to comment.
Loading...