Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何忽略特定的`<;div>;`同时使用响应语音API进行文本到语音转换_Javascript_Html_Responsivevoice - Fatal编程技术网

Javascript 如何忽略特定的`<;div>;`同时使用响应语音API进行文本到语音转换

Javascript 如何忽略特定的`<;div>;`同时使用响应语音API进行文本到语音转换,javascript,html,responsivevoice,Javascript,Html,Responsivevoice,我正在使用,我已经将这个插件合并到我的应用程序中 现在,如果您注意到插件在容器下正确地表达了给定的文章。我遇到的问题是我想忽略divid=“googleadframe”style=“border:0pt none;”>容器。插件会说出框架内的文本,我想忽略该文本。使用过此API的人是否能够成功地完成此操作 我对他们的API做了研究,并试图找到一些例子,但我没能做到。任何帮助都将不胜感激。以下是我的代码供示例参考: <!DOCTYPE html> <html> <h

我正在使用,我已经将这个插件合并到我的应用程序中

现在,如果您注意到插件在
容器下正确地表达了给定的文章。我遇到的问题是我想忽略
divid=“googleadframe”style=“border:0pt none;”>
容器。插件会说出框架内的文本,我想忽略该文本。使用过此API的人是否能够成功地完成此操作

我对他们的API做了研究,并试图找到一些例子,但我没能做到。任何帮助都将不胜感激。以下是我的代码供示例参考:

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>TestingOnlyDemo</title>
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://code.responsivevoice.org/responsivevoice.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            disableSourceEdit();
        });

        function speak(obj) {

                $("#listenBtn").hide();
                $("#speechoperation").show();
                responsiveVoice.speak($('#row_view').text(), "UK English Female");
        };

        function pause() {
            responsiveVoice.pause();
        };

        function resume() {
            responsiveVoice.resume();
        };

        function stop() {
            $("#listenBtn").show();
            $("#speechoperation").hide();
            responsiveVoice.cancel();
        };
    </script>
</head>
<body>
    <center>
        <div>
            <hgroup>
                <h2>Text To Speech Application Demo</h2>
            </hgroup>

            <div class="article_body" id="row_view">
                <div id="body"><p>This article includes definition, types of articles – a, an, the.There are example sentences.</p></div>
                <div id="googleadframe" style="border: 0pt none;"><iframe id="google_ads_iframe_/1055314/LM_MF_WAP_ePaper_Interstitial_0" title="3rd party ad content" name="google_ads_iframe_/1055314/LM_MF_WAP_ePaper_Interstitial_0" width="30" height="25" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" srcdoc="" data-google-container-id="3" style="border: 0px; vertical-align: bottom;" data-load-complete="true">HERE IS THE IFRAME THAT WE NEED TO HIDE</iframe></div>
                <div>The definite article is the word the. It limits the meaning of a noun to one particular thing.</div>
            </div>
            <div class="articulate-area">
                <button class="btn btn-primary" id="listenBtn" onclick="speak('article')">Listen</button>
                <span id="speechoperation" style="display:none">
                    <button class="btn btn-primary" onclick="pause()">Pause</button>
                    <button class="btn btn-primary" onclick="resume()">Resume</button>
                    <button class="btn btn-primary" onclick="stop()">Stop</button>
                </span>
            </div>
        </div>
    </center>
</body>
</html>

测试昂莱德莫
$(文档).ready(函数(){
disableSourceEdit();
});
功能发言(obj){
$(“#listenBtn”).hide();
$(“#speechoperation”).show();
responsiveVoice.speak($('row#u view').text(),“英国英语女性”);
};
函数暂停(){
(停顿);
};
功能恢复(){
resume();
};
函数停止(){
$(“#listenBtn”).show();
$(“#speechoperation”).hide();
responsiveVoice.cancel();
};
文本到语音应用程序演示
这篇文章包括定义,文章的类型-a,an,the。有例句

这是我们需要隐藏的IFRAME 定冠词是单词The。它把名词的意义限定在一个特定的事物上。 听 暂停 简历 停止
注意:我无法更改视图的
HTML
结构。当speak操作正在进行时,我需要一种忽略iframe div标记的方法。添加任何
div
元素都无助于解决此问题

提前谢谢


<!DOCTYPE html>

 <html>
  <head>
<meta name="viewport" content="width=device-width" />
<title>TestingOnlyDemo</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://code.responsivevoice.org/responsivevoice.js"> 
 </script>
 <script type="text/javascript">



    function speak(obj) {
       $("#listenBtn").hide();
        $("#speechoperation").show();

        responsiveVoice.speak($(".speak").text(), "UK English Female");
    };

    function pause() {
        responsiveVoice.pause();
    };

    function resume() {
        responsiveVoice.resume();
    };

    function stop() {
        $("#listenBtn").show();
        $("#speechoperation").hide();
        responsiveVoice.cancel();
    };
</script>
 </head>
  <body>
      <center>
       <div>
                <hgroup>
                  <h2>Text To Speech Application Demo</h2>
              </hgroup>

        <div class="article_body" >
            <div class="speak" id="body"><p>This article includes definition, types of articles – a, an, the.There are example sentences.</p></div>
            <div id="googleadframe" style="border: 0pt none;"><iframe id="google_ads_iframe_/1055314/LM_MF_WAP_ePaper_Interstitial_0" title="3rd party ad content" name="google_ads_iframe_/1055314/LM_MF_WAP_ePaper_Interstitial_0" width="30" height="25" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" srcdoc="" data-google-container-id="3" style="border: 0px; vertical-align: bottom;" data-load-complete="true">HERE IS THE IFRAME THAT WE NEED TO HIDE</iframe></div>
            <div  class="speak">The definite article is the word the. It limits the meaning of a noun to one particular thing.</div>
        </div>
        <div class="articulate-area">
            <button class="btn btn-primary" id="listenBtn" onclick="speak('article')">Listen</button>
            <span id="speechoperation" style="display:none">
                <button class="btn btn-primary" onclick="pause()">Pause</button>
                <button class="btn btn-primary" onclick="resume()">Resume</button>
                <button class="btn btn-primary" onclick="stop()">Stop</button>
            </span>
        </div>
    </div>
</center>
测试昂莱德莫 功能发言(obj){ $(“#listenBtn”).hide(); $(“#speechoperation”).show(); responsiveVoice.speak($(“.speak”).text(),“英国英语女性”); }; 函数暂停(){ (停顿); }; 功能恢复(){ resume(); }; 函数停止(){ $(“#listenBtn”).show(); $(“#speechoperation”).hide(); responsiveVoice.cancel(); }; 文本到语音应用程序演示 这篇文章包括定义,文章的类型-a,an,the。有例句

这是我们需要隐藏的IFRAME 定冠词是单词The。它把名词的意义限定在一个特定的事物上。 听 暂停 简历 停止


处的工作示例,不是讲述
#行(u)视图
的全部内容,而是讲述
#行(u)视图
中非广告框的每个子级的内容:

responsiveVoice.speak($('#row_view > :not(#googleadframe)').text(), "UK English Female");
请注意,这将仅从
#row_视图
的子元素中获取文本,而不是直接从其内部获取文本

<div class="article_body" id="row_view">
  ********THIS TEXT WILL NOT BE SPOKEN********
  <div id="body">
    <p>But this will.</p>
  </div>
  <div id="googleadframe" style="border: 0pt none;">Nothing in here</div>
  <div>Back to speaking</div>
</div>

********这篇课文将不发言********
但这会

这里什么都没有 回到话题上来
我无法理解您的答案。您能否举例说明如何使用
选择器?工作提琴可能会有所帮助。我已经更新了答案,也看到了工作演示谢谢你的答案,但不幸的是,这不是我想要的。我的
HTML
结构已修复,因此我无法添加/删除任何
classe
id
。我想要的是忽略iframe div,而不重新构造视图的
HTML
主体。我希望你能理解我在这里的意思。不要更改/删除任何类,只需添加类speak,我知道你在这里的意思,但我不能这样做,因为
HTML
结构是静态的。将其视为来自服务器的
HTML
页面。我也不能在
div
元素中添加任何
class
。我必须对它进行一些调整,以使我的案例生效,但这确实有帮助。谢谢