responsivevoice - 我必须将 html 元素内的文本读给声音机器人
responsivevoice - I have to read the text inside the html element to the sound robot
responsivevoice.org
我无法按照自己的意愿进行文字语音服务。
网站上没有详细解释
我不想使用
<div id = "text-read"> one two tree four five </div>
<button onclick="responsiveVoice.speak('text-read');" type="button" value="Play">Play</button>
我想让它用按钮阅读内容。
感谢您的关注
资源:
https://responsivevoice.org/api
https://responsivevoice.org/text-to-speech-sdk/text-to-speech-play-button
https://responsivevoice.org/text-to-speech-sdk/text-to-speech-widget
speak
函数的第一个参数表示要说的文字,第二个参数定义语音:
responsiveVoice.speak('bir, i̇ki, üç', 'Turkish Male');
如果你想获取某些 HTML 元素中的文本,you have to query it first, then get its text content 最后将其传递给函数:
var element = document.getElementById('text-read');
var text = element.innerText;
responsiveVoice.speak(text, 'Turkish Male');
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
<!-- Turkish Man Or Women Voice -->
var element = document.getElementById('#erkekoku');
var text = element.innerText || element.textContent;
element.innerHTML = erkekoku;
var element = document.getElementById('#erkekoku');
var text = element.innerText;
function manspeak(obj) {
responsiveVoice.speak($('#erkekoku').text(), 'Turkish Male');
};
</script>
<div id="erkekoku">Bu metni seslendirdim.</div>
<button class="btn btn-primary" onclick="manspeak('article')">Play</button>
responsivevoice.org 我无法按照自己的意愿进行文字语音服务。 网站上没有详细解释
我不想使用
<div id = "text-read"> one two tree four five </div>
<button onclick="responsiveVoice.speak('text-read');" type="button" value="Play">Play</button>
我想让它用按钮阅读内容。 感谢您的关注
资源:
https://responsivevoice.org/api
https://responsivevoice.org/text-to-speech-sdk/text-to-speech-play-button
https://responsivevoice.org/text-to-speech-sdk/text-to-speech-widget
speak
函数的第一个参数表示要说的文字,第二个参数定义语音:
responsiveVoice.speak('bir, i̇ki, üç', 'Turkish Male');
如果你想获取某些 HTML 元素中的文本,you have to query it first, then get its text content 最后将其传递给函数:
var element = document.getElementById('text-read');
var text = element.innerText;
responsiveVoice.speak(text, 'Turkish Male');
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
<!-- Turkish Man Or Women Voice -->
var element = document.getElementById('#erkekoku');
var text = element.innerText || element.textContent;
element.innerHTML = erkekoku;
var element = document.getElementById('#erkekoku');
var text = element.innerText;
function manspeak(obj) {
responsiveVoice.speak($('#erkekoku').text(), 'Turkish Male');
};
</script>
<div id="erkekoku">Bu metni seslendirdim.</div>
<button class="btn btn-primary" onclick="manspeak('article')">Play</button>