Speech Synthesize API不再正常工作

时间:2016-03-01 20:03:04

标签: php text-to-speech speech speech-synthesis

语音合成器API似乎只适用于英语。只有我吗?我在代码中做错了吗?或者它不适合其他人?对于某些语言,如中文和日语,它根本不输出任何声音,对于像西班牙语和其他语言这样的语言,它只是读取它们如何读取常规英语。这刚刚开始发生,也许是过去2周左右?在相同的准确代码正常工作之前。

<?php

  header('Content-Type: text/html; charset=utf-8');

?>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>

  $(function() {

  //te amo <--- spanish
  // 我爱你 <--- chinese

  var speech = "我爱你";
  document.write(speech);
  var u = new SpeechSynthesisUtterance(speech);

  u.lang = "zh-CN";
  u.volume = 1; //0-1 1=default
  u.rate = 0.5; //0-10, 1=default
  u.pitch = 1.9; //0-2 1=default

  window.speechSynthesis.speak(u);

});

</script>

供参考:

http://blog.teamtreehouse.com/getting-started-speech-synthesis-api

"arabic" => "ar-DZ",
"bulgarian" => "bg",
"catalan" => "ca",
"chinese-simplified" => "zh-CN",
"chinese-traditional" => "zh-CN",
"czech" => "cs",
"danish" => "da",
"dutch" => "nl-BE",
"english" => "en-US",
"estonian" => "et",
"finnish" => "fi",
"french" => "fr-BE",
"german" => "de-AT",
"greek" => "el",
"haitian-creole" => "en-US",
"hebrew" => "he",
"hindi" => "hi",
"hungarian" => "hu",
"indonesian" => "id",
"italian" => "it-IT",
"japanese" => "ja",
"klingon" => "en-US",
"korean" => "ko",
"latvian" => "lv",
"lithuanian" => "lt",
"malay" => "ms-BN",
"maltese" => "mt",
"norwegian" => "no-NO",
"persian" => "fa",
"polish" => "pl",
"portuguese" => "pt-BR",
"romanian" => "ro-MO",
"russian" => "ru",
"slovak" => "sk",
"slovenian" => "sl",
"spanish" => "es-AR",
"swedish" => "sv-FI",
"thai" => "th",
"turkish" => "tr",
"ukrainian" => "uk",
"urdu" => "ur",
"vietnamese" => "vi",
"welsh" => "cy",

0 个答案:

没有答案