I am putting together a project in which the site is based all over the Annyang library using this library, choosing to speak by microphone and this will execute commands.
I have my current javascript code
<script>
"use strict";
if (annyang) {
// Definimos nuestro primer comando. Primero escribimos el comando y posteriormente la función a ejecutar.
//api google AIzaSyCer2C9iE2qvsnCOm6cjGlEuYJRvqw18y0
//buscador facebook: https://www.facebook.com/search/top/?q=
//buscador google: https://www.google.com/search?q=
var commandos = {
'abajo': function() {
window.location.href = "#abajo";
},
'arriba': function() {
window.location.href = "#";
},
'siguiente': function() {
document.getElementById("siguiente").click();
},
'anterior': function() {
document.getElementById("anterior").click();
},
'cabecera': function() {
window.location.href = "#cabecera_1";
},
'foto uno': function() {
window.location.href = "#foto_1";
},
'foto dos': function() {
window.location.href = "#foto_2";
},
'foto tres': function() {
window.location.href = "#foto_3";
},
'enlace uno': function() {
document.getElementById("enlace_1").click();
},
'enlace dos': function() {
document.getElementById("enlace_2").click();
},
'enlace tres': function() {
document.getElementById("enlace_3").click();
},
'buscar ': function(tag) {
document.getElementById("buscador").select();
},
'buscar *tag': function cambiaValores(tag) {
var inputNombre = document.getElementById("buscador");
inputNombre.value = "*tag";
document.getElementById("enviar").click();
}
};
// Agregamos nuestros comandos a annyang.
annyang.addCommands(commandos);
//Establecemos el lenguaje, en mi caso es español de México (puedes ver la lista completa de lenguajes soportados aquí).
annyang.setLanguage("es-MX");
// Empezmaos a escuchar.
annyang.start();
}
This is the HTML
<form class="form-inline mt-2 mt-md-0" method="GET" action="http://www.google.com/search">
<input id="buscador" class="form-control mr-sm-2" name="q" type="text" placeholder="Buscar" aria-label="Buscar" value="">
<button id="enviar" class="btn btn-outline-success my-2 my-sm-0" type="submit">Buscar</button>
</form>
What I want the function to comply with I say Search "Toys" and automatically write Toys in the input of the search engine, once written this also meets the function document.getElementById("enviar").click();
What I have done is easy but I did not get the search engine and I tried the example of Flickr but there is no result.
Thank you very much