SpeechSynthesisUtterance 在为 Android 构建的 HTML5 应用程序中不起作用 [英] SpeechSynthesisUtterance not working in an HTML5 app built for Android

查看:198
本文介绍了SpeechSynthesisUtterance 在为 Android 构建的 HTML5 应用程序中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试使用 Intel xdk 构建一个 HTML5 应用程序.现在当我构建下面的代码作为适用于 Android 的 HTML5 应用程序并将其部署到我的 Android 设备上,执行以下功能时我听不到声音.

So i am trying to build an HTML5 app with the Intel xdk.Now when i build the code below as a HTML5 app for Android and deploy it to my Android device, i cannot hear the sound when the function below is executed.

function speak(){
        var foo = new SpeechSynthesisUtterance("Speech");
        foo.voice = voices.filter(function(voice) { return voice.name == 'Agnes'; })[0];
        foo.volume = 0.5; // 0 to 1
        foo.rate = 0.7; // 0.1 to 10
        foo.pitch = 0.8; //0 to 2
        //foo.lang = 'en-GB';
        window.speechSynthesis.speak(foo);
    }

我只是不知道设备上的 HTML5 应用程序是如何工作的,因为如果我将此功能放在一个 html 文件中并尝试在 Android 上的 Chrome 中访问它,它就可以正常工作.所以我的问题是,我需要做什么才能让这个 SpeechSynthesisUtterance 在 Android HTML5 应用程序中按预期工作.

I simply do not know how HTML5 apps on devices work, because if i put this function in a html file and try to access it in Chrome on Android, it works just fine. So my question is, just what do i need to do to get this SpeechSynthesisUtterance working as expected in an Android HTML5 app.

我的测试设备是运行最近发布的 4.3 Android 更新的三星 Galaxy S3.

My test device is a Samsung Galaxy S3 running the 4.3 Android update which was released very recently.

推荐答案

此功能在 Chrome 33 (公告).它不在 Android 网页视图中,因此它不适用于 XDK android 构建或任何cordova/phonegap 构建器.它将在人行横道 5 中可用,因此 XDK 人行横道 android 版本将在 3 月下旬人行横道 5 发布时提供.请参阅crosswalk 发布时间表

This feature is in Chrome 33 (announcement). It is not in the Android web view so it will not work with the XDK android build or any cordova/phonegap builder. It will be available in crosswalk 5, so the XDK crosswalk android build will have it in late March when crosswalk 5 is released. See crosswalk release schedule

这篇关于SpeechSynthesisUtterance 在为 Android 构建的 HTML5 应用程序中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆