From d7b986b7ab22dd6a7b31b0761021c018970fd56c Mon Sep 17 00:00:00 2001 From: allo Date: Tue, 11 Jan 2022 15:38:58 +0800 Subject: mv to .md for web/api/speechsynthesis/getvoices --- .../web/api/speechsynthesis/getvoices/index.html | 93 ---------------------- 1 file changed, 93 deletions(-) delete mode 100644 files/zh-cn/web/api/speechsynthesis/getvoices/index.html (limited to 'files/zh-cn/web/api/speechsynthesis/getvoices/index.html') 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 ---- -
{{APIRef("Web Speech API")}}{{SeeCompatTable}}
- -

The getVoices() method of the {{domxref("SpeechSynthesis")}} interface returns a list of {{domxref("SpeechSynthesisVoice")}} objects representing all the available voices on the current device.

- -

Syntax

- -
speechSynthesisInstance.getVoices();
-
- -

参数

- -

None.

- -

返回值

- -

返回一个类型为{{domxref("SpeechSynthesisVoice")}} 的数组(array)列表(list)。

- -
-

Note: 使用此方法会返回存在错误规范的SpeechSynthesisVoiceList 对象, 可能已被从现有规范中移除。

-
- -

示例

- -

JavaScript

- -
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;
-}
- -

HTML

- -
<select id="voiceSelect"></select>
-
- -

{{EmbedLiveSample("Example", 400, 25)}}

- -

Specifications

- - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('Web Speech API', '#dfn-ttsgetvoices', 'getVoices()')}}{{Spec2('Web Speech API')}}Initial definition
- -

Browser compatibility

- -
- - -

{{Compat("api.SpeechSynthesis.getVoices")}}

-
- -

See also

- - -- cgit v1.2.3-54-g00ecf