I plan to convert text to speech on certain events. What are the languages supported by the Web Speech API?
Asked
Active
Viewed 1,041 times
2 Answers
3
The voices supported depend on the browser and operating system. This has evolved over time as more voices are added.
I wrote a JSBin that displays a browser's voices in that OS: https://output.jsbin.com/dehoyavize
"use strict";
/** Draw table from array of objects **/
const drawTable = (obArr, tableDiv) => {
const table = document.createElement('table');
// Table header row
const thr = document.createElement('tr');
for (const p in obArr[0]) {
// Get column headers from voice attributes
const th = document.createElement('th');
th.appendChild(document.createTextNode(p));
thr.appendChild(th);
}
table.appendChild(thr);
// Build rows
for (const obj of obArr) {
const tr = document.createElement('tr');
for (const p in obj) {
// Build table from each voice's attribute values
const td = document.createElement('td');
td.appendChild(document.createTextNode(obj[p]));
tr.appendChild(td);
}
table.appendChild(tr);
};
// Add table to document
tableDiv.appendChild(table);
};
/** get w3c voices **/
if ('speechSynthesis' in window) {
const tableDiv = document.querySelector('#tableDiv');
let voices = speechSynthesis.getVoices();
if (voices.length) {
// Safari; FF caches voices after 1st load
drawTable(voices, tableDiv);
} else {
// Opera win, Firefox 1st load, Chrome
speechSynthesis.onvoiceschanged = () => {
voices = speechSynthesis.getVoices();
drawTable(voices, tableDiv);
};
}
} else {
// No window.speechSynthesis thus no voices
// Opera android, etc.
document.querySelector('#tableDiv').innerText = 'This browser has no voices';
}
table, td, th {
border: 1px solid black;
font-family: sans-serif;
}
tr:nth-child(even) {
background-color: #eee;
}
<body>
<div id="tableDiv">
</div>
</body>

Frazer
- 1,049
- 1
- 10
- 16
1
In one old thread, I found the information that below languages are supported.
var langs =
[['Afrikaans', ['af-ZA']],
['Bahasa Indonesia',['id-ID']],
['Bahasa Melayu', ['ms-MY']],
['Català', ['ca-ES']],
['Čeština', ['cs-CZ']],
['Deutsch', ['de-DE']],
['English', ['en-AU', 'Australia'],
['en-CA', 'Canada'],
['en-IN', 'India'],
['en-NZ', 'New Zealand'],
['en-ZA', 'South Africa'],
['en-GB', 'United Kingdom'],
['en-US', 'United States']],
['Español', ['es-AR', 'Argentina'],
['es-BO', 'Bolivia'],
['es-CL', 'Chile'],
['es-CO', 'Colombia'],
['es-CR', 'Costa Rica'],
['es-EC', 'Ecuador'],
['es-SV', 'El Salvador'],
['es-ES', 'España'],
['es-US', 'Estados Unidos'],
['es-GT', 'Guatemala'],
['es-HN', 'Honduras'],
['es-MX', 'México'],
['es-NI', 'Nicaragua'],
['es-PA', 'Panamá'],
['es-PY', 'Paraguay'],
['es-PE', 'Perú'],
['es-PR', 'Puerto Rico'],
['es-DO', 'República Dominicana'],
['es-UY', 'Uruguay'],
['es-VE', 'Venezuela']],
['Euskara', ['eu-ES']],
['Français', ['fr-FR']],
['Galego', ['gl-ES']],
['Hrvatski', ['hr_HR']],
['IsiZulu', ['zu-ZA']],
['Íslenska', ['is-IS']],
['Italiano', ['it-IT', 'Italia'],
['it-CH', 'Svizzera']],
['Magyar', ['hu-HU']],
['Nederlands', ['nl-NL']],
['Norsk bokmål', ['nb-NO']],
['Polski', ['pl-PL']],
['Português', ['pt-BR', 'Brasil'],
['pt-PT', 'Portugal']],
['Română', ['ro-RO']],
['Slovenčina', ['sk-SK']],
['Suomi', ['fi-FI']],
['Svenska', ['sv-SE']],
['Türkçe', ['tr-TR']],
['български', ['bg-BG']],
['Pусский', ['ru-RU']],
['Српски', ['sr-RS']],
['한국어', ['ko-KR']],
['中文', ['cmn-Hans-CN', '普通话 (中国大陆)'],
['cmn-Hans-HK', '普通话 (香港)'],
['cmn-Hant-TW', '中文 (台灣)'],
['yue-Hant-HK', '粵語 (香港)']],
['日本語', ['ja-JP']],
['Lingua latīna', ['la']]];
Reference:
What are the supported languages for Web Speech API in HTML5?
I suggest you also check the browser compatibility of web speech API.

Deepak-MSFT
- 10,379
- 1
- 12
- 19
-
Does that page use the API that OP linked to? It appears to use Google's own. – Frazer Apr 07 '20 at 09:23