标签: speech-synthesis

Web语音API:始终在iOS Safari上获得支持的语音合成语音

我正试图在iOS Safari上获得支持的语音合成语音列表.

根据API,我应该能够通过调用以获得一系列声音:

window.speechSynthesis.getVoices();
Run Code Online (Sandbox Code Playgroud)

有时这会给我一些声音列表,有时却没有.请参阅以下jsfiddle:https://jsfiddle.net/sq7xf327/

如果我在iPhone 5(iOS 8.1.3)上打开它,我不会得到一致的结果.有时我会收回所有37个声音,有时我会收到0个声音.如果你继续刷新它偶尔会显示37或0.

我知道在Chrome中你可以添加一个事件监听器

window.speechSynthesis.voiceschanged 
Run Code Online (Sandbox Code Playgroud)

事件以了解语音何时加载,但Safari中不支持此事件.

我试过的一个技巧是定期检查:

var timer = setInterval(function () {
    window.voices_ = window.speechSynthesis.getVoices();
    if (window.voices_.length > 0) {
        clearInterval(timer);
    }
}, 1000);
Run Code Online (Sandbox Code Playgroud)

这也没有给我一致的结果.

知道如何在iOS Safari上可靠且始终如一地获得支持的语音合成语音吗?

javascript safari speech-synthesis ios

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

android chrome 中的语音合成不加载语音

我有一个在 Windows chrome 上正确运行的脚本,但是当我在 android chrome 上尝试它时,它不起作用。这似乎是声音的问题,因为:

if ('speechSynthesis' in window)
Run Code Online (Sandbox Code Playgroud)

返回真。我尝试了一些在线示例(例如http://codepen.io/matt-west/pen/wGzuJ),并且“声音”选择列表为空。

我需要安装一些东西才能使其工作吗?

此代码适用于 Windows 的 chrome,但不适用于 Android 的 chrome:

function playSentence(text) {    
     var msg = new SpeechSynthesisUtterance();    
     msg.text = text;
     window.speechSynthesis.speak(msg);
 }

 $(function () {
     playSentence("Hello world");
 });
Run Code Online (Sandbox Code Playgroud)

版本:Android 5.0.0 - Chrome 46.0.2490.76

android google-chrome speech-synthesis

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

语音合成API突出显示单词

目前,我正在制作一个简单的应用程序,使用语音合成API说出文本.我想强调说出来的话(粗体).我目前有一个非常基本的实现,使用'onboundary'事件.但是,我想知道是否有更好/更好的方法,因为我的实现基于一些假设.

var words;
var wordIdx;
var text;
var utterance = new SpeechSynthesisUtterance();
utterance.lang = 'en-UK';
utterance.rate = 1;

window.onload = function(){
    document.getElementById('textarea').innerText = 'This is a text area.  It is used as a simple test to check whether these words are highlighted as they are spoken using the web speech synthesis API (utterance).';

    document.getElementById('playbtn').onclick = function(){
        text    = document.getElementById('textarea').innerText;
        words   = text.split(' ');
        wordIdx = 0;

        utterance.text = text;
        speechSynthesis.speak(utterance);
    }

    utterance.onboundary = function(event){
        var e = document.getElementById('textarea');
        var it …
Run Code Online (Sandbox Code Playgroud)

html javascript speech-synthesis

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

将语音文化转换为其他语言

除了英国文化,我还有一些文字.例如:泰米尔文化.

如果我不提及文化,将采用默认英语.

如何将文本转换为语音(英语除外)?

代码段:

对于英语:

public static void ConvertTextToVoice()
    {
        SpeechSynthesizer speech = new SpeechSynthesizer();
        speech.Volume = 100;
        speech.Rate = 0;            
        speech.Speak("Welcome to india");
    }
Run Code Online (Sandbox Code Playgroud)

对于其他语言:

public static void ConvertTextToVoice()
{
    SpeechSynthesizer speech = new SpeechSynthesizer();
    speech.Volume = 100;
    speech.Rate = 0;

    //Tamil Text
    string text = "??????? ???? ??????? ????? ???????? ?????? ???? ???? ???";

    PromptBuilder builder = new PromptBuilder(new System.Globalization.CultureInfo("ta-IN"));
    builder.AppendText(text);           
    speech.SpeakAsync(builder);
}
Run Code Online (Sandbox Code Playgroud)

c# culture text-to-speech speech-synthesis

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

speechSynthesis.getVoices()在Windows上返回空数组

我正在制作一个Chrome扩展程序,其中正在使用语音合成。当我speechSynthesis.getVoices()控制台中键入内容时,我会得到21种不同声音数组。大!

当我console.log()在JavaScript代码中的同一行时,在控制台中出现一个空数组。怎么了,我不知道!

javascript windows arrays voice speech-synthesis

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

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
查看次数

自M71以来,不再允许未经用户激活的JavaScript speechSynthesis.speak()

我以这种方式使用了SpeechSynthesis API:

speechSynthesis.speak(new SpeechSynthesisUtterance("hello world"));
Run Code Online (Sandbox Code Playgroud)

但是现在更新Google Chrome后出现错误:

自2018年12月左右以来,自M71开始,不再允许未经用户激活的[Deprecation] speechSynthesis.speak()。有关更多详细信息,请参见 https://www.chromestatus.com/feature/5687444770914304

如何解决此问题并寻求许可?

javascript google-chrome speech-synthesis

6
推荐指数
3
解决办法
4053
查看次数

Google Cloud文字转语音字时间戳

我正在通过Google Cloud的文本到语音API生成语音,我想在说出单词时突出显示它们。

是否可以获取口语或句子的时间戳记?

text-to-speech speech-synthesis google-text-to-speech

6
推荐指数
3
解决办法
123
查看次数

System.Speech.Synthesis的事件信息中的流编号在哪里?

可以让SpeechSynthesizer以异步方式讲文本,例如:

Private WithEvents _Synth As New SpeechSynthesizer

Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
    If e.KeyCode = Keys.Enter Then
        _Synth.SpeakAsync(New Prompt(Me.TextBox1.Text))
    End If
End Sub
Run Code Online (Sandbox Code Playgroud)

SpeechSynthesizer产生的事件使我们能够分辨出计算机语音在说什么。

例如,您可以通过选择以下字符来可视化语音输出:

Private Sub _Synth_SpeakProgress(sender As Object, e As SpeakProgressEventArgs) Handles _Synth.SpeakProgress

    Me.TextBox1.SelectionStart = e.CharacterPosition
    Me.TextBox1.SelectionLength = e.CharacterCount

End Sub
Run Code Online (Sandbox Code Playgroud)

但是,当SpeakAsync反复被调用时(例如,当我们告诉SpeechSyntesizer他们当前正在讲话时说相同的文本时),语音请求会排队,然后SpeechSynthesizer一一播放。

但是,我无法找出合成器当前正在发出哪个请求。在SpeakProgressEventArgs不透露这个

使用SAPI5,事件提供了StreamNumber

Parameters
StreamNumber
    The stream number which generated the event. When a voice enqueues more than one …
Run Code Online (Sandbox Code Playgroud)

.net vb.net speech-synthesis speechsynthesizer

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

在 chrome android 上使用 voiceSynthesis.resume() 恢复暂停的语音不起作用

使用浏览器 api voiceSynthesis.resume() 我正在尝试在 android chrome 上恢复暂停的语音

我已经在 mac os mojave 上的 chrome 桌面版本 78.0.3904.97 上测试了下面的代码,它在演讲暂停后恢复演讲,没有任何问题。但相同的代码无法在 android chrome 版本 77.x 和 78.x 上恢复演讲

重现步骤

  1. 运行下面的代码
  2. 按播放键收听演讲
  3. 讲话中途暂停
  4. 按简历
  5. 在桌面版 chrome 上可以恢复语音,但在 Android chrome 上则无法恢复语音

这是 Chrome 中的错误吗?

<!DOCTYPE html>
<html>
  <head>
    <title>Parcel Sandbox</title>
    <meta charset="UTF-8" />
  </head>

  <body>
    <button id="play">Play</button>
    <button id="pause">Pause</button>
    <button id="resume">Resume</button>

    <div id="data"></div>

    <script>
      const play = document.getElementById("play");
      const pause = document.getElementById("pause");
      const resume = document.getElementById("resume");

      play.addEventListener("click", function() {
        document.getElementById("data").innerText = "play";
        var utterance = new SpeechSynthesisUtterance( …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome text-to-speech speech-synthesis web-audio-api

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