0

responsivevoice .org 我无法按照自己的意愿进行文本语音服务。网站上没有详细的解释。

我不想用 <textarea> 我想用的例子。我不想选择机器人。它应该只说土耳其男性。我该怎么做?

<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/文本转语音小部件

4

2 回答 2

0
<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>
于 2020-05-30T23:06:40.410 回答
0

函数的第一个参数speak表示要说的文本,第二个参数定义语音:

responsiveVoice.speak('bir, i̇ki, üç', 'Turkish Male');

如果要获取某个 HTML 元素中的文本,则必须先查询它,然后获取其文本内容,最后将其传递给函数:

var element = document.getElementById('text-read');
var text = element.innerText;
responsiveVoice.speak(text, 'Turkish Male');
于 2020-05-30T20:56:20.953 回答