SpeechLib.SpVoiceClass:GetVoices确实崩溃了我的Unity可执行文件

时间:2014-09-12 00:01:47

标签: c# dll unity3d text-to-speech

我用Unity创建了一个项目(版本4.5.3f3)。 我只写了一个简单的脚本如下:

using UnityEngine;
using System.Collections;
using SpeechLib;

public class SpeechTest : MonoBehaviour
{
    private SpVoice voice;

    void Start()
    {
        voice = new SpVoice();
        voice.GetVoices("","");
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.anyKeyDown)
        {
            voice.Speak("Hello, world!", SpeechVoiceSpeakFlags.SVSFlagsAsync);
        }
    }
}

您可以在此下载Unity的测试项目:https://dl.dropboxusercontent.com/u/12184013/TextToSpeech.zip

当我尝试播放(在Unity编辑器中)时,游戏运行没有问题。 相反,当我构建并运行游戏时,它会崩溃。

当我评论这一行时

ISpeechObjectTokens voices = voice.GetVoices();

重建后游戏不会崩溃。

我需要调用GetVoices方法,因为我想在“SpVoice语音”对象中设置一个新的声音。

1 个答案:

答案 0 :(得分:0)

以下是解决方案:http://forum.unity3d.com/threads/speechlib-spvoiceclass-getvoices-does-crash-my-unity-executable.268011/#post-1772720

简而言之,Unity项目中应包含库[Unity安装目录] \ Editor \ Data \ Mono \ lib \ mono \ 2.0 \ CustomMarshalers.dll(将其添加为资产)。