- Home /
speech animals not run
using UnityEngine; using System; using System.Collections.Generic; using System.Text; using DotNetSpeech;
public class NewBehaviourScript : MonoBehaviour { SpVoice voice = new SpVoiceClass(); SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; public Texture2D[] m_iMouthBmp; string text="I love unity3d."; int i; string VisemeId ="viseme"; public GUISkin myskin ;
void OnGUI () {
GUI.skin = myskin;
GUI.Label(new Rect (20, 20, 120, 50),VisemeId);
if(GUI.Button (new Rect (20, 60, 120, 50), "speak")) {
voice.Viseme += new _ISpeechVoiceEvents_VisemeEventHandler(voice_Viseme);
voice.Speak(text, SpFlags);
voice.WaitUntilDone(-4);
renderer.material.mainTexture = m_iMouthBmp[i];
}
}
void voice_Viseme(int StreamNumber, object StreamPosition, int Duration, SpeechVisemeType NextVisemeId, SpeechVisemeFeature Feature, SpeechVisemeType CurrentVisemeId) {
VisemeId= CurrentVisemeId.ToString().Replace("SP_VISEME_","");
//VisemeId = CurrentVisemeId.ToString();
if(VisemeId == "15"|| VisemeId =="17"||VisemeId =="18"||VisemeId =="21") {
i=1;
} else {
i=0;
}
}
}
The script passed,the program not.There is a runtime error:This application has requested the runtime to terminate it in a unusual way..... why?
Fixed code formatting (that's the nice thing about being able to edit questions ... but this one was a tough case ... what a mess ;-) )
Answer by jashan · Sep 01, 2010 at 12:26 PM
It looks like DotNetSpeech is not compatible with Unity, or maybe you're calling it the wrong way. That's about as much as I can say with the given information.