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

46

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

例如:

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

谢谢!


没有找到关于该API支持的语言的足够信息。请阅读此链接:http://lists.w3.org/Archives/Public/public-xg-htmlspeech/2011Feb/att-0020/api-draft.html - ridoy
4个回答

76

好的,如果它没有发布,我们可以尝试至少解决这个问题。我会先放置这张表格,如果有人有更多信息,我们会进行完善。

我做出的假设是,支持的语言应该类似于语音搜索支持的语言,并且谷歌使用标准语言代码,并在其服务中保持一致性。

我已经在维基百科上查找了语音搜索支持的语言。

我在这里谷歌语言设置页面这里找到了语言代码。

编辑: 我已经尝试过后端语音识别服务。我运行了一系列测试,每次将相同的英语语音样本传递给API,但每次指定不同的方言。看起来:

如果不支持某种语言,则识别将回退到 en-US(看起来它能够识别样本是英文的)。如果不支持某种方言(或不存在该方言),则识别将回退到主方言或在某些情况下回退到 en-US。主方言可以指定为标识符的第一部分。因此,'en-US' 和 'en' 会得到相同的结果。对于一些语言(如中文和日语)的识别结果是英文的,与 en-US 不同,这很奇怪。可能样本与中文差异很大,服务聪明地想出了这一点。
如果识别结果与 en-US 和该语言的主方言不同,则我认为该方言受到支持。但为了确保100%,我们需要为每种语言运行样本。
图例
  • + 最受支持,因为测试结果与en-US和主要方言不同。
  • .+ 在维基百科上没有列出,但是最受支持,因为测试结果与en-US和主要方言不同。
  • +? 最受支持,因为在维基百科上有列出。但是我的样本测试结果与主要方言相同。所以可能是巧合,也可能是语言代码错误。
  • .+? 没有在维基百科上列出,但看起来是被支持的,因为测试结果与en-US和主要方言不同。

语言

  • + 阿非利堪斯语 af
  • + 巴斯克语 eu
  • + 保加利亚语 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
  • + 法语 fr-FR
  • + 加利西亚语 gl
  • + 德语 de-DE
  • + 希伯来语 he
  • + 匈牙利语 hu
  • + 冰岛语 is
  • + 意大利语

支持的语言将与Android的语音识别服务相同吗? - weilou
1
我不知道。根据网络上的众多消息来源,语音输入API使用私人谷歌端点,因此识别是在谷歌服务器上完成的。我的假设是,为语音搜索和语音输入API执行识别的服务可能是相同的(但不一定是真的)。 - Sergey Zyuzin
阿拉伯语对我来说都是一样的。 - tofutim
可能的方法是编写脚本下载每个样例,并对结果进行哈希。检查哪些是不同的。 - tofutim
@Sergey Zyuzin:波斯语怎么样? - Behnam
最后一个链接现在是http://www.personal.psu.edu/ejp10/symbolcodes/bylanguage/index.html。 - Maxime Lechevallier

21

我知道这篇帖子很旧,但由于这些信息难以找到,所以我想为那些正在寻找的人发布一个列表。如果您发现任何错误或遗漏,请留言。

{
  "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


5
使用以下代码获取浏览器中语音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语音API(尽管Safari仅支持文本到语音功能)。奇怪的是Firefox OS支持TTS,但浏览器版本不支持。

可用的语言列表取决于您所使用的浏览器,根据文档和我的测试(用户代理相关)。

在Safari中,您还可以使用许多语言(我相信超过40种)。在此时的Chrome中,您将获得以下列表:

Voice 0 Google美式英语undefined

Voice 1 Google英式男性英语undefined

Voice 2 Google英式女性英语undefined

Voice 3 Google西班牙语undefined

Voice 4 Google法语undefined

Voice 5 Google意大利语undefined

Voice 6 Google德语undefined

Voice 7 Google日语undefined

Voice 8 Google韩语undefined

Voice 9 Google中文undefined

Voice 10 本机undefined


1
这个问题是关于语音识别的...但它只给出了语音合成/TTS的列表。 - TimHayes
当时,我认为它只能识别它能够合成的相同语言。难道不是这样吗? - mesosteros
2
我认为它们并不相互连接,尽管我确信它们很相似。我发现谷歌云语音API中的下拉列表对Web语音API的识别非常准确。https://cloud.google.com/speech/ - TimHayes
很酷。不过我觉得那时候还不存在这个东西 ;) - mesosteros

0
这里有一个 LinkedHashMap,其中包含@TimHayes,您可以从中提取值。我正在使用LinkedHashMap,所以我可以获得地图的位置。
    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");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接