[responsevoice-我必须将html元素内的文本阅读给声音机器人

问题描述 投票:0回答:1

responsevoice .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/apihttps://responsivevoice.org/text-to-speech-sdk/text-to-speech-play-buttonhttps://responsivevoice.org/text-to-speech-sdk/text-to-speech-widget

javascript html api text-to-speech responsivevoice
1个回答
0
投票

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');
© www.soinside.com 2019 - 2024. All rights reserved.