如何在使用响应式语音 API 进行文本转语音时忽略特定的“<div>”
How to ignore a particular `<div>` while using Responsive Speech API for Text-To-Speech
我正在使用ResponsiveSpeech API and I have incorporated this plugin in my sample working application。
现在,如果您在这里观察到插件正确朗读 <div id="row_view">
容器下的给定文章。我遇到的问题是我想忽略 div id="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>
注意:我无法更改视图的 HTML
结构。当说话操作正在进行时,我需要一种方法来忽略 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>
的工作示例
与其说出 #row_view
的全部内容,不如说出 #row_view
的每个子广告框架以外的内容:
responsiveVoice.speak($('#row_view > :not(#googleadframe)').text(), "UK English Female");
请注意,这只会从 #row_view
的 子元素 抓取文本,而不是直接在其中抓取文本。
<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>
我正在使用ResponsiveSpeech API and I have incorporated this plugin in my sample working application。
现在,如果您在这里观察到插件正确朗读 <div id="row_view">
容器下的给定文章。我遇到的问题是我想忽略 div id="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>
注意:我无法更改视图的 HTML
结构。当说话操作正在进行时,我需要一种方法来忽略 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>
的工作示例
与其说出 #row_view
的全部内容,不如说出 #row_view
的每个子广告框架以外的内容:
responsiveVoice.speak($('#row_view > :not(#googleadframe)').text(), "UK English Female");
请注意,这只会从 #row_view
的 子元素 抓取文本,而不是直接在其中抓取文本。
<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>