小编Fra*_*zer的帖子

Android-Chrome 中的 SpeechSynthesis:无法更改美国英语的英语语音

我正在 Android-Chrome 上使用语音合成 API。问题是,尽管有 4 种英语语音可用,但无论代码指定什么,浏览器始终使用美国英语。我可以使用其他语言,例如法语,但不能使用其他英语语音,例如 en-AU、GB 或 IN。

此代码从 getVoices 数组中过滤英式英语语音对象,并使用第一个说出单词“tomato”的对象。问题是这个词总是发音为“to-may-lo”而不是“to-mar-to”,这意味着我的文本不押韵。

显示使用的语音对象(在我尝试过的手机上)是 GB 的。

html...

<!DOCTYPE html>
<html lang="en-GB">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Let's not call the whole thing off</title>
        <script src="tomato.js" defer></script>
    </head>
    <body>
        <div id="tomato" lang="en-GB">Tomato</div>
        <div id="platform"></div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

还有剧本...

var platform = document.getElementById("platform");
var tomato = document.getElementById("tomato");

var voices = [];
var voicesGB = [];
voices = speechSynthesis.getVoices();
speechSynthesis.onvoiceschanged = function() {
    voices = speechSynthesis.getVoices();
    voicesGB = voices.filter(voice => /en(-|_)GB/.test(voice.lang));
};

function speak(word) { …
Run Code Online (Sandbox Code Playgroud)

javascript text-to-speech speech-synthesis android-chrome

6
推荐指数
1
解决办法
2964
查看次数

网络语音API语法

有人能告诉我这是什么吗

 const grammar = '#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghost | white | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple …
Run Code Online (Sandbox Code Playgroud)

javascript speech-recognition ecmascript-6 webspeech-api

3
推荐指数
1
解决办法
309
查看次数