【问题标题】:Titanium Text-to-Speech钛文字转语音
【发布时间】:2014-08-28 08:59:22
【问题描述】:

我正在使用 ~Link~ 在 Titanium 中为 android 创建文本到语音功能,但我在开发中遇到了一些问题。

模块支持 TTS 和 STT,STT 功能正常但另一个不工作。

我按照文档创建这样的控制器:

var utterance = require('bencoding.utterance'), Speech = utterance.createSpeech();

if(speech.isSpeaking){
        Ti.API.info("already speaking");
    }

    speech.startSpeaking({
        text:"こんにちは"
    }); 

当我运行程序时。控制台将显示:

[ERROR] :  TiApplication: (main) [1191,10337] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.3.0,2014/07/11 12:36,787cd39
[ERROR] :  TiApplication: java.lang.NullPointerException
[ERROR] :  TiApplication:   at bencoding.utterance.SpeechProxy.onInit(SpeechProxy.java:72)
[ERROR] :  TiApplication:   at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:640)
[ERROR] :  TiApplication:   at android.speech.tts.TextToSpeech.access$1000(TextToSpeech.java:52)
[ERROR] :  TiApplication:   at android.speech.tts.TextToSpeech$Connection.onServiceConnected(TextToSpeech.java:1296)
[ERROR] :  TiApplication:   at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1187)
[ERROR] :  TiApplication:   at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1204)
[ERROR] :  TiApplication:   at android.os.Handler.handleCallback(Handler.java:615)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java:92)
[ERROR] :  TiApplication:   at android.os.Looper.loop(Looper.java:155)
[ERROR] :  TiApplication:   at android.app.ActivityThread.main(ActivityThread.java:5511)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
[ERROR] :  TiApplication:   at dalvik.system.NativeStart.main(Native Method)

即使我从示例中复制代码。

是我的问题吗?模块被添加到程序中。

谢谢。

【问题讨论】:

    标签: titanium text-to-speech


    【解决方案1】:

    我使用 Titanium 3.3.0GA 编译该模块并且可以使用 the example。你用的是什么版本?

    将此代码用于测试设备很重要:

    win.addEventListener('open', function()
    {
        if(!utterance.isSupported())
        {
           alert("Device not compatible");
        }
    });
    

    【讨论】:

    • 感谢您的回复。我发现模块运行正常但不会说日语(示例文本),如果我将其更改为数字或英语将起作用。
    猜你喜欢
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 2011-03-04
    相关资源
    最近更新 更多