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

本文关键字:坏了 我的 Unity 可执行文件 SpVoiceClass GetVoices SpeechLib | 更新日期: 2023-09-27 18:21:45

我用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 voice"对象中设置一个新的语音。

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

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

简而言之,库[Unity Install Directory]''Editor''Data''Mono''lib''Mono''2.0''CustomMarshallers.dll应包含在Unity项目中(将其作为资产添加)。