What are language codes in Chrome's implementation of the HTML5 speech recognition API?

后端 未结 4 1193
迷失自我
迷失自我 2021-01-30 05:40

Chrome implemented the HTML5 speech recognition API. Many languages are supported. I wanna know which languages are supported and each language\'s corresponding code which is us

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 06:06

    Use the following code to get all available voices for the speech API in your browser:

    var voices = speechSynthesis.getVoices();
          for(var i = 0; i < voices.length; i++ ) {
            console.log("Voice " + i.toString() + ' ' + voices[i].name + ' ' + voices[i].uri);
          }
    

    At this time only Chrome and Safari support the Web Speech API (although Safari only supports the Text to Speech functionalities). Curiously Firefox OS supports TTS but the browser version does not.

    The list of languages depends on what browser you are on according to both the documentation and my tests (user agent dependent).

    In Safari you also get lots of languages available (I believe over 40). In Chrome, at this time you get the following list:

    Voice 0 Google US English undefined

    Voice 1 Google UK English Male undefined

    Voice 2 Google UK English Female undefined

    Voice 3 Google Español undefined

    Voice 4 Google Français undefined

    Voice 5 Google Italiano undefined

    Voice 6 Google Deutsch undefined

    Voice 7 Google 日本人 undefined

    Voice 8 Google 한국의 undefined

    Voice 9 Google 中国的 undefined

    Voice 10 native undefined

提交回复
热议问题