Speech to text button in textbox on a webpage

2019-04-13 23:28发布

问题:

Is is possible to have a working Google speech to text button in a textbox on a webpage?

How can it be done?

回答1:

it's an HTML5 thingy ...

<input type="text" id="txtSearch" x-webkit-speech />

so, will only work in available browsers.

Live code: http://jsbin.com/afifaw/3



回答2:

This is a really crude implementation of TTS that you might find acceptable. It's going to need some tender love and care, but it's a starting point.

<p id="tts">The maximum number of characters, including punctuation marks and all spaces, that I can read is 100</p>

<a target="new" id="ttsLink" onclick="document.getElementById('ttsReader').src='http://translate.google.com/translate_tts?tl=en&q='+encodeURIComponent(document.getElementById('tts').innerHTML)">  <u>click me<u></a>

<br/ ><br />
<iframe id="ttsReader" width="10" height="10"></iframe>