javascript Text to Speech arabic

2019-07-08 02:34发布

I'm trying to make SpeechSynthesisUtterance work for Arabic

It's working fine for English

$(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>

But when Arabic is used

$(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>

Any idea what I'm doing wrong?

1条回答
Animai°情兽
2楼-- · 2019-07-08 03:16

The SpeechSynthesisUtterance function doesn't support Arabic, and only supports the following languages with their respective voices :

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

查看更多
登录 后发表回答