First off I am trying to create a temporary solution that I don't expect to work forever. Just an experiment if you will!
I have the following running! What I am trying to do is initiate the voice search on page load. Any ideas for a way to get this working! Note: You will need chrome browser to see the mic input.
http://jsfiddle.net/dirtyd77/99amf/
<html>
<head>
<style>
#mike {
font-size: 25px;
width: 25px;
height: 25px;
cursor:pointer;
border: none;
position: absolute;
margin-left: 5px;
outline: none;
background: transparent;
}
#txt {
height: 150px;
width: 150px;
}
</style>
<script>
var mike = document.getElementById('mike');
mike.onfocus = mike.blur;
mike.onwebkitspeechchange = function(e) {
console.log(e); // SpeechInputEvent
document.getElementById('txt').value = mike.value;
};
</script>
</head>
Make sure it's plugged in and powered on. Make sure it's connected to the internet and on the same Wi-Fi network as your mobile device. Make sure the microphone is turned on: Speakers (except Google Home), Smart Displays, or Smart Clocks: On the back of your device, make sure the switch for the microphone is turned on.
Unfortunately, this is not possible. The most important reason being that it would be an invasion of privacy/security hazard. A user must willingly choose to be recorded (in this case, by mouseclick). If the event can be emulated and the user is unaware that they are being recorded, there could be serious legal repercussions. Hope this helps!
UPDATE:
This is from a document about Speech Input
:
To minimize the chance of users unwittingly let web pages record speech without their knowledge, implementations must abort an active speech input session if the web page lost input focus to another window or to another tab within the same user agent.
Here are concerns from that same document :
1) Spoken password inputs can be problematic from a security perspective, but it is up to the user to decide if they want to speak their password.
2) Speech input could potentially be used to eavesdrop on users. Malicious webpages could use tricks such as hiding the input element or otherwise making the user believe that it has stopped recording speech while continuing to do so. They could also potentially style the input element to appear as something else and trick the user into clicking them. An example of styling the file input element can be seen at http://www.quirksmode.org/dom/inputfile.html. The above recommendations are intended to reduce this risk of such attacks.
Also, according to this article from html5rocks.com:
the first time speech recognition is used, Chrome needs to ask the user for permission to use the microphone, in which case onstart only fires when and if the user allows permission.
With this in mind, it would be very difficult, if not nearly impossible, to implement onload
events without the user's consent, since Google has taken measures to protect against malicious webpages
. Google has also prevented users from simulating click events.
After trying a bunch of stuff and researching, I found that:
You cannot programmatically activate the speech input. This is to prevent abuse. https://code.google.com/p/html5rocks/issues/detail?id=594
That's from google.
Tried like hell to make the jFiddle work. Used a bunch of jquery functions, tried target to simulate a click, a few third party stuff -- looks they've got it pretty well secured.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With