diff options
author | allo <yin199909@aliyun.com> | 2022-01-11 15:38:58 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-01-19 01:00:39 +0800 |
commit | d7b986b7ab22dd6a7b31b0761021c018970fd56c (patch) | |
tree | a18de9cf5625f88c6941de7b39606d66d4db2282 /files/zh-cn/web/api/speechsynthesis/getvoices/index.html | |
parent | 8d30d00ee0443d71b9666394070b5205e785eacc (diff) | |
download | translated-content-d7b986b7ab22dd6a7b31b0761021c018970fd56c.tar.gz translated-content-d7b986b7ab22dd6a7b31b0761021c018970fd56c.tar.bz2 translated-content-d7b986b7ab22dd6a7b31b0761021c018970fd56c.zip |
mv to .md for web/api/speechsynthesis/getvoices
Diffstat (limited to 'files/zh-cn/web/api/speechsynthesis/getvoices/index.html')
-rw-r--r-- | files/zh-cn/web/api/speechsynthesis/getvoices/index.html | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/files/zh-cn/web/api/speechsynthesis/getvoices/index.html b/files/zh-cn/web/api/speechsynthesis/getvoices/index.html deleted file mode 100644 index 5d66a40799..0000000000 --- a/files/zh-cn/web/api/speechsynthesis/getvoices/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: SpeechSynthesis.getVoices() -slug: Web/API/SpeechSynthesis/getVoices -translation_of: Web/API/SpeechSynthesis/getVoices ---- -<div>{{APIRef("Web Speech API")}}{{SeeCompatTable}}</div> - -<p>The <code><strong>getVoices()</strong></code> method of the {{domxref("SpeechSynthesis")}} interface returns a list of {{domxref("SpeechSynthesisVoice")}} objects representing all the available voices on the current device.</p> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">speechSynthesisInstance.getVoices(); -</pre> - -<h3 id="参数">参数</h3> - -<p>None.</p> - -<h3 id="返回值">返回值</h3> - -<p>返回一个类型为{{domxref("SpeechSynthesisVoice")}} 的数组(array)列表(list)。</p> - -<div class="note"> -<p><strong>Note</strong>: 使用此方法会返回存在错误规范的<code>SpeechSynthesisVoiceList</code> 对象, 可能已被从现有规范中移除。</p> -</div> - -<h2 id="示例">示例</h2> - -<h3 id="JavaScript">JavaScript</h3> - -<pre class="brush: js">function populateVoiceList() { - if(typeof speechSynthesis === 'undefined') { - return; - } - - voices = speechSynthesis.getVoices(); - - for(i = 0; i < voices.length ; i++) { - var option = document.createElement('option'); - option.textContent = voices[i].name + ' (' + voices[i].lang + ')'; - - if(voices[i].default) { - option.textContent += ' -- DEFAULT'; - } - - option.setAttribute('data-lang', voices[i].lang); - option.setAttribute('data-name', voices[i].name); - document.getElementById("voiceSelect").appendChild(option); - } -} - -populateVoiceList(); -if (typeof speechSynthesis !== 'undefined' && speechSynthesis.onvoiceschanged !== undefined) { - speechSynthesis.onvoiceschanged = populateVoiceList; -}</pre> - -<h3 id="HTML">HTML</h3> - -<pre class="brush: html"><select id="voiceSelect"></select> -</pre> - -<p>{{EmbedLiveSample("Example", 400, 25)}}</p> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('Web Speech API', '#dfn-ttsgetvoices', 'getVoices()')}}</td> - <td>{{Spec2('Web Speech API')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div> - - -<p>{{Compat("api.SpeechSynthesis.getVoices")}}</p> -</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Web/API/Web_Speech_API">Web Speech API</a></li> -</ul> |