gpt4 book ai didi

javascript - 当页面自动刷新但不在谷歌浏览器中时,语音在 Firefox 中被切断

转载 作者:可可西里 更新时间:2023-11-01 02:26:59 25 4
gpt4 key购买 nike

我有这个问题,在 Firefox 中,如果页面自动刷新,语音会被切断,但在谷歌浏览器中,即使页面自动刷新,它也会完成语音。如何修复它,以便即使页面自动刷新,语音也不会在 Firefox 中被切断?

msg = new SpeechSynthesisUtterance("please finish saying this entire sentence.");
window.speechSynthesis.speak(msg);

(function ($) {
'use strict';
if (window == window.top) {
var body = $('body').empty();
var myframe = $('<iframe>')
.attr({ src: location.href })
.css({ height: '95vh', width: '100%' })
.appendTo(body)
.on('load', function () {
var interval;
interval = 750;
setTimeout(function () {
myframe.attr({ src: location.href });
}, interval);
});
}
})(jQuery);

最佳答案

I have this problem where in firefox the speech gets cut off if the page is auto-refreshed, but in google chrome it finishes saying the speech even if the page is auto-refreshed.



所描述的 Firefox 行为是一个合理的预期实现。

浏览 source code Firefox 和 Chromium 的实现 speechSynthesis.speak()基于与本地语音服务器的套接字连接。 *nix 上的那个服务器通常是 speech-dispatcher speechd ( speech-dispatcher )。见 How to programmatically send a unix socket command to a system server autospawned by browser or convert JavaScript to C++ souce code for Chromium?有关尝试在 Chromium 上实现 SSML 解析的描述。

最终决定根据 W3C 规范使用 JavaScript 编写自己的代码来实现该要求 SpeechSynthesisSSMLParser在 SE 站点上询问了不止一个问题、提交问题和错误并在 W3C 邮件列表上发布后,没有任何证据表明 SSML 解析将作为 Web Speech API 的一部分包含在内。

一旦该连接被启动,就会为对 .speak() 的调用创建一个队列。 .即使连接关闭 Task Manager可能仍会显示服务注册的事件进程。

Chromium/Chrome 的过程并非没有错误,与问题中描述的内容最接近的过程是
  • Issue 797624: "speak speak slash" is audio output of .speak() following two calls to .speak(), .pause() and .resume()
  • Why hasn't Issue 88072 and Issue 795371 been answered? Are Internals>SpeechSynthesis and Blink>Speech dead? (可能的原因是“但在谷歌浏览器中,即使页面自动刷新,它也会完成语音。”在 Chrome 中仍然可能)
  • .volume属性(property)问题
  • Issue 797512: Setting SpeechSynthesisUtterance.volume does not change volume of audio output of speechSynthesis.speak() ( Chrome / Chrome )
  • Bug 1426978 Setting SpeechSynthesisUtterance.volume does not change volume of audio output of speechSynthesis.speak() (火狐)

  • 最严重的问题是 Chromium/Chrome webkitSpeechReconition记录用户的音频并将该音频数据发布到远程服务的实现,在那里将转录本返回到浏览器 - 没有明确通知用户正在发生的事情,标记为 WONT FIX
  • Issue 816095: Does webkitSpeechRecognition send recorded audio to a remote web service by default?

  • GitHub 上的相关 W3C Speech API 问题
  • The UA should be able to disallow speak() from autoplaying #27
  • Precisely define when speak() should fail due to autoplay rules #35 (具有讽刺意味的是,与此问题中描述的 Chromium/Chrome 上报告的行为和输出相关,请参阅 Web Audio, Autoplay Policy and GamesAutoplay Policy Changes)
  • Intent to Deprecate: speechSynthesis.speak without user activation

    Summary

    The SpeechSynthesis API is actively being abused on the web. We don’t have hard data on abuse, but since other autoplay avenues are starting to be closed, abuse is anecdotally moving to the Web Speech API, which doesn't follow autoplay rules.

    After deprecation, the plan is to cause speechSynthesis.speak to immediately fire an error if specific autoplay rules are not satisfied. This will align it with other audio APIs in Chrome.

  • Timing of SpeechSynthesis state changes not defined #39
  • Timing of SpeechSynthesisUtterance events firing not defined #40
  • Clarify what happens if two windows try to speak #47


  • 总之,不会将 Firefox 的行为描述为“问题”,而是将 Chrome 的行为描述为潜在的“问题”。

    在浏览器中深入研究 W3C Web Speech API 实现并非易事。有几个原因。包括商业 TTS/SST 服务的明显重点或可用选项,以及“智能手机”中语音合成和语音识别的专有闭源实现;代替解决在现代浏览器中实际部署 W3C Web Speech API 的各种问题。
    speechd的维护者(speech-dispatcher) 对服务器端(本地 speech-dispatcher 套接字)非常有帮助。

    不能代表 Firefox 维护者。如果 .speak() 提交与继续执行音频输出的功能请求相关的错误,则估计不太可能。来自重装 window与浏览器最近实现的自动播放策略一致。尽管您仍然可以提交 Firefox 错误,以询问在重新加载当前 window 期间是否预计会继续音频输出(来自任何 API 或接口(interface))。 ;以及是否有任何偏好或政策可以设置为覆盖所描述的行为,如@zip 的回答所建议的那样。并从实现者自己那里得到答案。

    有编写 FOSS 代码的个人和团体在该领域很活跃并愿意帮助 SST/TTS 开发,其中许多人在 GitHub 上很活跃,这是询问有关如何实现您想要具体实现的目标的另一种选择在 Firefox 浏览器中。

    除了向实现者询问功能请求之外,您还可以阅读源代码并尝试创建一种或多种变通方法。替代方法包括使用 meSpeak.js ,但如果 Firefox 在重新加载 window 期间有意阻止音频输出,这仍然不一定解决。 .

    关于javascript - 当页面自动刷新但不在谷歌浏览器中时,语音在 Firefox 中被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54328556/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com