Speech to text button in textbox on a webpage

2019-04-13 23:29发布

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

enter image description here

How can it be done?

2条回答
看我几分像从前
2楼-- · 2019-04-13 23:33

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>
查看更多
甜甜的少女心
3楼-- · 2019-04-13 23:40

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

enter image description here

查看更多
登录 后发表回答