void Speak(string s) { #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN WindowsVoice.Speak(s); #else InfinityEngine.Localization.SpeechEngine.Speak(s); #endif }
public void SendChat(string text) { //print(GetSocket.SocketSendReceive(server,Convert.ToInt32(port),user + Char.MinValue + bot + Char.MinValue +text.text+ Char.MinValue)); //netSock.SendMsg("\0"+"\0"+"\0"); string msg = user + " " + bot + " " + text; print("Message to send: " + msg); WindowsVoice.Speak(netSock.SendMsg(user, bot, text)); }
public void Speak(ThingPart thingPart, string text, VoiceProperties properties) { if (voice == null) { try { voice = gameObject.AddComponent <WindowsVoice>() as WindowsVoice; voice.Init(); } catch (Exception exception) { voice = null; Log.Debug("Failed to initialize Windows Voice"); } } if (voice != null) { bool hasSurroundSound = false; Thing thing = thingPart.transform.parent.gameObject.GetComponent <Thing>(); if (thing != null) { hasSurroundSound = thing.hasSurroundSound; } Vector3 ourPosition = Managers.personManager.ourPerson.Head.transform.position; float distance = Vector3.Distance(ourPosition, thingPart.transform.position); const float maxDistanceToHear = 12.5f; const float startOfHearingFallOff = 2f; float relativeVolume = 1f; if (distance > startOfHearingFallOff && !hasSurroundSound) { relativeVolume = 1f - (distance - startOfHearingFallOff) / (maxDistanceToHear - startOfHearingFallOff); } const float generalVolumeAdjust = 0.5f; relativeVolume *= generalVolumeAdjust; if (properties == null) { properties = new VoiceProperties(); } VoiceProperties adjustedProperties = new VoiceProperties(); adjustedProperties.gender = properties.gender; adjustedProperties.volume = (int)((float)properties.volume * relativeVolume); adjustedProperties.pitch = properties.pitch; adjustedProperties.speed = properties.speed; if (adjustedProperties.volume > 0) { voice.Speak(text, adjustedProperties); } } }
private void OnPhraseRecognized(PhraseRecognizedEventArgs args) { WindowsVoice.Speak("Initiating " + args.text); keywords[args.text].Invoke(); StringBuilder builder = new StringBuilder(); builder.AppendFormat("{0} ({1}){2}", args.text, args.confidence, Environment.NewLine); builder.AppendFormat("Timestamp: {0}{1}", args.phraseStartTime, Environment.NewLine); builder.AppendFormat("Duration: {0} seconds{1}", args.phraseDuration.TotalSeconds, Environment.NewLine); Debug.Log(builder.ToString()); }