javascript文字转语音阿拉伯语

时间:2019-02-08 11:02:01

标签: javascript jquery text-to-speech

我正在尝试使SpeechSynthesisUtterance适用于阿拉伯语

英语很好用

$(document).ready(function() {
  var u1 = new SpeechSynthesisUtterance('Hello world!');
  u1.lang = 'en-US';
  u1.pitch = 20;
  u1.rate = 1;
  u1.voiceURI = 'native';
  u1.volume = 1000;
  speechSynthesis.speak(u1);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

但是使用阿拉伯语

$(document).ready(function() {
  var u1 = new SpeechSynthesisUtterance('عربي');
  u1.lang = 'ar-AE';
  u1.pitch = 20;
  u1.rate = 1;
  u1.voiceURI = 'native';
  u1.volume = 1000;
  speechSynthesis.speak(u1);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

知道我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

SpeechSynthesisUtterance功能不支持阿拉伯语,only supports the following languages不支持它们的声音:

speechSynthesis.onvoiceschanged = function() {
  var voices = this.getVoices();
  console.log(voices);
};