Chrome实现HTML5语音识别API的语言代码是什么?

h6my8fg2  于 2022-12-30  发布在  Go
关注(0)|答案(4)|浏览(134)

Chrome实现了HTML5语音识别API。支持多种语言。我想知道支持哪些语言以及HTML元素的lang属性中使用的每种语言的对应代码。
例如:

  • 波兰语(pl-PL)
  • 土耳其语(tr-TR)

谢谢大家!

ar7v8xwq

ar7v8xwq1#

好吧,如果它没有发表,我们至少可以试着弄清楚这一点。让我把这个表格放在开头,如果有人有更多的信息,我们会改进它。
我假设支持的语言应该与语音搜索支持的语言相似,谷歌使用标准的语言代码,并在其服务中保持一致。
我在wikipedia上查找了语音搜索支持的语言
我在google language settings pagehere上找到了语言代码here

**EDIT:**我已经试验过后端语音识别服务。我运行了一系列测试,在这些测试中,我将相同的英语语音样本传递给API,但每次都指定不同的方言。

  • 如果不支持某种语言,则识别福尔斯退到en-US(看起来它识别的样本是英语)
  • 如果方言不受支持(或不存在),则在某些情况下,识别福尔斯到主方言或en-US
  • 可以将主要方言指定为标识符的第一部分。因此“en-US”和“en”给出相同的结果。
  • 对一些语言的识别,如中文和日文,给出的结果是英语,与en-US不同,这很奇怪。可能样本与中文有很大不同,服务很聪明地发现了这一点。

如果识别结果与en-US和该语言的主要方言不同,我将该方言视为受支持的。不过,为了100%验证它,我们需要运行每种语言的样本。

图例

  • +大多数都支持,因为test给出的结果与en-US和主要方言不同。
  • .+在维基百科上不存在,但大多数都支持,因为测试给出的结果与英语和主要方言不同。
  • +?大多数都支持,因为它在维基百科上列出。但测试我的样本给出的结果与主要方言相同。所以这要么是一个coinsidense或语言代码是错误的。
  • .+?未在维基百科上列出,但看起来支持,因为测试给出的结果与英语和主要方言不同。
    语文
  • +南非荷兰语af
  • +巴斯克语欧盟
  • +保加利亚语bg
  • +加泰罗尼亚语ca
  • +阿拉伯语(埃及)ar-EG
  • +?阿拉伯语(约旦)ar-JO
  • +阿拉伯语(科威特)ar-KW
  • +?阿拉伯语(黎巴嫩)ar-LB
  • +阿拉伯语(卡塔尔)ar-QA
  • +阿拉伯语(阿联酋)ar-AE
  • .+阿拉伯语(摩洛哥)ar-MA
  • .+阿拉伯语(伊拉克)ar-IQ
  • .+阿拉伯语(阿尔及利亚)ar-DZ
  • .+阿拉伯语(巴林)ar-BH
  • .+阿拉伯语(利比亚)ar-LY
  • .+阿拉伯语(阿曼)ar-OM
  • .+阿拉伯语(沙特阿拉伯)ar-SA
  • .+阿拉伯语(突尼斯)ar-TN
  • .+阿拉伯语(也门)ar-YE
  • +捷克文cs
  • +荷兰语nl-NL
  • +英语(澳大利亚)en-AU
  • +?英语(加拿大)en-CA
  • +英语(印度)en-IN
  • +英语(新西兰)en-NZ
  • +英语(南非)en-ZA
  • +英语(英国)en-GB
  • +英语(美国)en-US
  • +芬兰语fi
  • +法语法语-法语
  • +加利西亚语gl
  • +德语德语版
  • +希伯来语he
  • +匈牙利语hu
  • +冰岛语
  • +意大利语it-IT
  • +印度尼西亚语id
  • +日语ja
  • +朝鲜语ko
  • +拉丁文la
  • +普通话zh-CN
  • +传统台湾zh-TW
  • +?简体中文版zh-CN
  • +简体中文香港zh-HK
  • +粤语(繁体香港)zh-yue
  • +马来西亚ms-年度
  • +挪威语否-否
  • +波兰语pl
  • +?Pig拉丁语xx-Pig拉丁语
  • +葡萄牙语pt-PT
  • .+葡萄牙语(巴西)pt-BR
  • +罗马尼亚语ro-RO
  • +俄文俄文
  • +塞尔维亚语sr-SP
  • +斯洛伐克语sk
  • +西班牙语(阿根廷)es-AR
  • +西班牙语(玻利维亚)es-BO
  • +?西班牙语(智利)es-CL
  • +?西班牙语(哥伦比亚)es-CO
  • +?西班牙语(哥斯达黎加)es-CR
  • +西班牙语(多米尼加共和国)es-DO
  • +西班牙语(厄瓜多尔)es-EC
  • +西班牙语(萨尔瓦多)es-SV
  • +西班牙语(危地马拉)es-GT
  • +西班牙语(洪都拉斯)es-HN
  • +西班牙语(墨西哥)es-MX
  • +西班牙语(尼加拉瓜)es-NI
  • +西班牙语(巴拿马)es-PA
  • +西班牙语(巴拉圭)es-PY
  • +西班牙语(秘鲁)es-PE
  • +西班牙语(波多黎各)es-PR
  • +西班牙语(西班牙)es-ES
  • +西班牙语(美国)es-US
  • +西班牙语(乌拉圭)es-UY
  • +西班牙语(委内瑞拉)es-VE
  • +瑞典语sv-SE
  • +土耳其语tr
  • +祖鲁语祖语
gj3fmq9x

gj3fmq9x2#

我知道这是一个老帖子,但由于这些信息很难找到,我想我会张贴一个名单,任何人谁可能会寻找。请留下一个便条,如果你发现任何错误或遗漏。

{
  "Afrikaans": [
    ["South Africa", "af-ZA"]
  ],
  "Arabic" : [
    ["Algeria","ar-DZ"],
    ["Bahrain","ar-BH"],
    ["Egypt","ar-EG"],
    ["Israel","ar-IL"],
    ["Iraq","ar-IQ"],
    ["Jordan","ar-JO"],
    ["Kuwait","ar-KW"],
    ["Lebanon","ar-LB"],
    ["Morocco","ar-MA"],
    ["Oman","ar-OM"],
    ["Palestinian Territory","ar-PS"],
    ["Qatar","ar-QA"],
    ["Saudi Arabia","ar-SA"],
    ["Tunisia","ar-TN"],
    ["UAE","ar-AE"]
  ],
  "Basque": [
    ["Spain", "eu-ES"]
  ],
  "Bulgarian": [
    ["Bulgaria", "bg-BG"]
  ],
  "Catalan": [
    ["Spain", "ca-ES"]
  ],
  "Chinese Mandarin": [
    ["China (Simp.)", "cmn-Hans-CN"],
    ["Hong Kong SAR (Trad.)", "cmn-Hans-HK"],
    ["Taiwan (Trad.)", "cmn-Hant-TW"]
  ],
  "Chinese Cantonese": [
    ["Hong Kong", "yue-Hant-HK"]
  ],
  "Croatian": [
    ["Croatia", "hr_HR"]
  ],
  "Czech": [
    ["Czech Republic", "cs-CZ"]
  ],
  "Danish": [
    ["Denmark", "da-DK"]
  ],
  "English": [
    ["Australia", "en-AU"],
    ["Canada", "en-CA"],
    ["India", "en-IN"],
    ["Ireland", "en-IE"],
    ["New Zealand", "en-NZ"],
    ["Philippines", "en-PH"],
    ["South Africa", "en-ZA"],
    ["United Kingdom", "en-GB"],
    ["United States", "en-US"]
  ],
  "Farsi": [
    ["Iran", "fa-IR"]
  ],
  "French": [
    ["France", "fr-FR"]
  ],
  "Filipino": [
    ["Philippines", "fil-PH"]
  ],
  "Galician": [
    ["Spain", "gl-ES"]
  ],
  "German": [
    ["Germany", "de-DE"]
  ],
  "Greek": [
    ["Greece", "el-GR"]
  ],
  "Finnish": [
    ["Finland", "fi-FI"]
  ],
  "Hebrew" :[
    ["Israel", "he-IL"]
  ],
  "Hindi": [
    ["India", "hi-IN"]
  ],
  "Hungarian": [
    ["Hungary", "hu-HU"]
  ],
  "Indonesian": [
    ["Indonesia", "id-ID"]
  ],
  "Icelandic": [
    ["Iceland", "is-IS"]
  ],
  "Italian": [
    ["Italy", "it-IT"],
    ["Switzerland", "it-CH"]
  ],
  "Japanese": [
    ["Japan", "ja-JP"]
  ],
  "Korean": [
    ["Korea", "ko-KR"]
  ],
  "Lithuanian": [
    ["Lithuania", "lt-LT"]
  ],
  "Malaysian": [
    ["Malaysia", "ms-MY"]
  ],
  "Dutch": [
    ["Netherlands", "nl-NL"]
  ],
  "Norwegian": [
    ["Norway", "nb-NO"]
  ],
  "Polish": [
    ["Poland", "pl-PL"]
  ],
  "Portuguese": [
    ["Brazil", "pt-BR"],
    ["Portugal", "pt-PT"]
  ],
  "Romanian": [
    ["Romania", "ro-RO"]
  ],
  "Russian": [
    ["Russia", "ru-RU"]
  ],
  "Serbian": [
    ["Serbia", "sr-RS"]
  ],
  "Slovak": [
    ["Slovakia", "sk-SK"]
  ],
  "Slovenian": [
    ["Slovenia", "sl-SI"]
  ],
  "Spanish": [
    ["Argentina", "es-AR"],
    ["Bolivia", "es-BO"],
    ["Chile", "es-CL"],
    ["Colombia", "es-CO"],
    ["Costa Rica", "es-CR"],
    ["Dominican Republic", "es-DO"],
    ["Ecuador", "es-EC"],
    ["El Salvador", "es-SV"],
    ["Guatemala", "es-GT"],
    ["Honduras", "es-HN"],
    ["México", "es-MX"],
    ["Nicaragua", "es-NI"],
    ["Panamá", "es-PA"],
    ["Paraguay", "es-PY"],
    ["Perú", "es-PE"],
    ["Puerto Rico", "es-PR"],
    ["Spain", "es-ES"],
    ["Uruguay", "es-UY"],
    ["United States", "es-US"],
    ["Venezuela", "es-VE"]
  ],
  "Swedish": [
    ["Sweden", "sv-SE"]
  ],
  "Thai": [
    ["Thailand", "th-TH"]
  ],
  "Turkish": [
    ["Turkey", "tr-TR"]
  ],
  "Ukrainian": [
    ["Ukraine", "uk-UA"]
  ],
  "Vietnamese": [
    ["Viet Nam", "vi-VN"]
  ],
  "Zulu": [
    ["South Africa", "zu-ZA"]
  ]
}

编辑:我还找到了这个列表,可能是更当前的:https://cloud.google.com/speech-to-text/docs/languages
编辑2:添加以下样本声音列表:https://cloud.google.com/text-to-speech/docs/voices

liwlm1x9

liwlm1x93#

使用以下代码获取浏览器中语音API的所有可用语音:

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

目前只有Chrome和Safari支持Web Speech API(尽管Safari只支持文本到语音功能)。奇怪的是,Firefox OS支持TTS,但浏览器版本不支持。
根据文档和我的测试,语言列表取决于您使用的浏览器(取决于用户代理)。
在Safari浏览器中你也有很多语言可用(我相信超过40种)。在Chrome浏览器中,你会得到下面的列表:
语音0谷歌美国英语未定义
语音1谷歌英国英语男性未定义
语音2谷歌英国英语女性未定义
语音3谷歌西班牙语未定义
语音4谷歌法语未定义
语音5谷歌意大利语未定义
语音6谷歌多伊奇未定义
Voice 7 Google 日本人 undefined
语音8 Google未定义
Voice 9 Google 中国的 undefined
语音10本机未定义

o2g1uqev

o2g1uqev4#

这里你有一个LinkedHashMap中的@TimHayes,你可以在那里获取值。我使用LinkedHashMap,所以我可以得到Map的位置。

LinkedHashMap<String,String> country = new LinkedHashMap<String,String>();

    country.put("South Africa", "af-ZA");
    country.put("Algeria", "ar-DZ");
    country.put("Bahrain", "ar-BH");
    country.put("Egypt", "ar-EG");
    country.put("Israel", "ar-IL");
    country.put("Iraq", "ar-IQ");
    country.put("Jordan", "ar-JO");
    country.put("Kuwait", "ar-KW");
    country.put("Lebanon", "ar-LB");
    country.put("Morocco", "ar-MA");
    country.put("Oman", "ar-OM");
    country.put("Palestinian Territory", "ar-PS");
    country.put("Qatar", "ar-QA");
    country.put("Saudi Arabia", "ar-SA");
    country.put("Tunisia", "ar-TN");
    country.put("UAE", "ar-AE");
    country.put("Spain", "eu-ES");
    country.put("Bulgaria", "bg-BG");
    country.put("Spain", "ca-ES");
    country.put("China (Simp.)", "cmn-Hans-CN");
    country.put("Hong Kong SAR (Trad.)", "cmn-Hans-HK");
    country.put("Taiwan (Trad.)", "cmn-Hant-TW");
    country.put("Hong Kong", "yue-Hant-HK");
    country.put("Croatia", "hr_HR");
    country.put("Czech Republic", "cs-CZ");
    country.put("Denmark", "da-DK");
    country.put("Australia", "en-AU");
    country.put("Canada", "en-CA");
    country.put("India", "en-IN");
    country.put("Ireland", "en-IE");
    country.put("New Zealand", "en-NZ");
    country.put("Philippines", "en-PH");
    country.put("South Africa", "en-ZA");
    country.put("United Kingdom", "en-GB");
    country.put("United States", "en-US");
    country.put("Iran", "fa-IR");
    country.put("France", "fr-FR");
    country.put("Philippines", "fil-PH");
    country.put("Spain", "gl-ES");
    country.put("Germany", "de-DE");
    country.put("Greece", "el-GR");
    country.put("Finland", "fi-FI");
    country.put("Israel", "he-IL");
    country.put("India", "hi-IN");
    country.put("Hungary", "hu-HU");
    country.put("Indonesia", "id-ID");
    country.put("Iceland", "is-IS");
    country.put("Italy", "it-IT");
    country.put("Switzerland", "it-CH");
    country.put("Japan", "ja-JP");
    country.put("Korea", "ko-KR");
    country.put("Lithuania", "lt-LT");
    country.put("Malaysia", "ms-MY");
    country.put("Netherlands", "nl-NL");
    country.put("Norway", "nb-NO");
    country.put("Poland", "pl-PL");
    country.put("Brazil", "pt-BR");
    country.put("Portugal", "pt-PT");
    country.put("Romania", "ro-RO");
    country.put("Russia", "ru-RU");
    country.put("Serbia", "sr-RS");
    country.put("Slovakia", "sk-SK");
    country.put("Slovenia", "sl-SI");
    country.put("Argentina", "es-AR");
    country.put("Bolivia", "es-BO");
    country.put("Chile", "es-CL");
    country.put("Colombia", "es-CO");
    country.put("Costa Rica", "es-CR");
    country.put("Dominican Republic", "es-DO");
    country.put("Ecuador", "es-EC");
    country.put("El Salvador", "es-SV");
    country.put("Guatemala", "es-GT");
    country.put("Honduras", "es-HN");
    country.put("México", "es-MX");
    country.put("Nicaragua", "es-NI");
    country.put("Panamá", "es-PA");
    country.put("Paraguay", "es-PY");
    country.put("Perú", "es-PE");
    country.put("Puerto Rico", "es-PR");
    country.put("Spain", "es-ES");
    country.put("Uruguay", "es-UY");
    country.put("United States", "es-US");
    country.put("Venezuela", "es-VE");
    country.put("Sweden", "sv-SE");
    country.put("Thailand", "th-TH");
    country.put("Turkey", "tr-TR");
    country.put("Ukraine", "uk-UA");
    country.put("Viet Nam", "vi-VN");
    country.put("South Africa", "zu-ZA");

相关问题