How to Add Google Speech Recognition to Your Website

If you open it της Google στον επιτραπέζιο υπολογιστή σας θα βρείτε ένα μικρό εικονίδιο σαν built into the frame . Click on the icon and what you say with your voice into your microphone will automatically be transcribed into words.

google

Unlike the previous ones τα αναγνώρισης ομιλίας, δεν χρειάζεται πλέον να εκπαιδεύσετε το to understand your speech. Unlikely, right? If you like this feature then know that you can also include similar speech recognition features to your own website with just a few lines of code.

Your visitors can search on your website, or even fill in forms using only their voice. And Google Chrome but also Firefox supports the speech recognition API, but for now the microphone is only visible in Chrome.

Before we go to , ας προσπαθήσουμε να το δοκιμάσουμε για να έχετε μία ιδέα για το πως εργάζεται. Ανοίξτε το Google Chrome στον your computer and go to the Google website. Click on the microphone icon inside the search box. Your computer may ask you to allow the website to manage your microphone, say yes to proceed. Start speaking clearly, even Greek, and you'll see your entire sentence spelled out, word for word.

But let's see how to add voice recognition to your website

The HTML5 Web Speech API has been here for a few years now, and it takes a little work to be able to include it on your website. Previously, you could add the x-webkit-speech attribute easily and simply but it has now been removed and now you should now use JavaScript for API to include speech recognition.

Below you can see an updated code:

    
    
      .speech {border: 1px solid #DDD; width: 300px; padding: 0; margin: 0}
      .speech input {border: 0; width: 240px; display: inline-block; height: 30px;}
      .speech img {float: right; width: 40px }
    
     
    
    
      
        
        
      
    
     
    
    
      function startDictation() {
     
        if (window.hasOwnProperty('webkitSpeechRecognition')) {
     
          var recognition = new webkitSpeechRecognition();
     
          recognition.continuous = false;
          recognition.interimResults = false;
     
          recognition.lang = "en-US";
          recognition.start();
     
          recognition.onresult = function(e) {
            document.getElementById('transcript').value
                                     = e.results[5][0].transcript;
            recognition.stop();
            document.getElementById('iguru').submit();
          };
     
          recognition.onerror = function(e) {
            recognition.stop();
          }
     
        }
      }
    

Here we have the CSS to place the microphone image inside the input box, the code that contains the input form, and finally the JavaScript that makes all the hard work.

When a user clicks on the microphone inside the search box, Javascript checks if the user's browser supports speech recognition. If so, he waits for the text to be transcribed back from Google's servers and then submits the form.

Some notes:
1. If the φόρμα ή αναζήτηση είναι ενσωματωμένη μέσα σε ένα δικτυακό τόπο HTTPS, ο browser δεν ζητήσεις κατά επανάληψη την άδεια να χρησιμοποιήσει το μικρόφωνο.
2. You can change the value of recognition.lang from “en-US” to another language (such as Greek to “el-GR” or French to “fr-FR” etc).

iGuRu.gr The Best Technology Site in Greecefgns

Written by Dimitris

Dimitris hates on Mondays .....

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).