Comment: Taobao has been searching for voice on voice for a while, but I don’t seem to see any related blogs or posts talking about how to implement this. Today I checked some information and found that the implementation is so simple. Interested friends can refer to it.
I have been searching on Taobao for a while, but I don’t seem to see any related blogs or posts talking about how to implement this. Today I checked some information and found that the implementation is so simple. Maybe it’s because it’s too simple, so no one has discussed it.
In fact, the implementation only requires one sentence of code:
x-webkit-speech
What did you think of when you saw this code? Yes, this means that voice search only supports webkit kernel browsers, so where should this code be placed?
<input type="text" x-webkit-speech>
Just put it in the text input box, don't do anything else, see
Of course there are some other parameters, such as setting the speech restriction language types
<input type="text" x-webkit-speech lang="zh-CN">
There are also parameters for setting voice input syntax, which is a comparison to use in search boxes. After adding this parameter, the system will automatically remove meaningless words such as
<input type="text" x-webkit-speech x-webkit-grammar="bUIltin:search">
Of course, a small problem was found during the test, that is, when the page with voice search is an iframe page, after clicking on the microphone, please start talking, the floating layer will not follow the input input box.
Related reading: HTML5 voice search (Taobao store voice search)