private static System.Collections.Generic.List <Extension> getExtensionsFromExtensionFilters(ExtensionFilter[] extensions) { System.Collections.Generic.List <Extension> list = new System.Collections.Generic.List <Extension>(); if (extensions != null && extensions.Length > 0) { foreach (ExtensionFilter filter in extensions) { list.Add(new Extension(filter.Name, filter.Extensions)); Debug.Log("filter.Extensions: " + filter.Extensions.CTDump()); } } else { list.Add(new Extension(Util.Constants.TEXT_ALL_FILES, "*")); } if (Util.Config.DEBUG) { Debug.Log("getExtensionsFromExtensionFilters: " + list.CTDump()); } return(list); }
private System.Collections.Generic.List <Extension> getExtensionsFromExtensionFilters(ExtensionFilter[] extensions) { System.Collections.Generic.List <Extension> list = new System.Collections.Generic.List <Extension>(); if (extensions != null && extensions.Length > 0) { foreach (ExtensionFilter filter in extensions) { list.Add(new Extension(filter.Name, filter.Extensions)); //Debug.Log($"filter.Extensions: {filter.Extensions.CTDump()}"); } } else { list.Add(new Extension(allFilesText, "*")); } if (Util.Config.DEBUG) { Debug.Log($"getExtensionsFromExtensionFilters: {list.CTDump()}"); } return(list); }
private IEnumerator multiTreaded() { Debug.Log("Starting..."); while (!Manager.BadWordManager.isReady) { yield return(null); } //System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.ContainsMT(out containsUnwantedWords, DirtyText)); System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.GetAllMT(out unwantedWords, DirtyText)); //System.Threading.Thread worker = new System.Threading.Thread(() => BWFManager.ReplaceAllMT(out cleanText, DirtyText)); //System.Threading.Thread worker = new System.Threading.Thread(() => BadWordManager.ReplaceAllMT(out CleanText, DirtyText)); worker.Start(); Debug.Log("Checking..."); do { yield return(null); } while (worker.IsAlive); Debug.Log("Finished: " + System.Environment.NewLine + unwantedWords.CTDump()); }
/* * /// <summary>Bridge to the native tts system</summary> * /// <param name="id">Identifier of the voice to speak.</param> * /// <param name="text">Text to speak.</param> * /// <param name="rate">Speech rate of the speaker in percent (default: 1, optional).</param> * /// <param name="pitch">Pitch of the speech in percent (default: 1, optional).</param> * /// <param name="volume">Volume of the speaker in percent (default: 1, optional).</param> * [System.Runtime.InteropServices.DllImport("__Internal")] * extern static public void Speak(string id, string text, float rate = 1f, float pitch = 1f, float volume = 1f); */ #endif /// <summary>Receives all voices</summary> /// <param name="voicesText">All voices as text string.</param> public static void SetVoices(string voicesText) { #if (UNITY_IOS || UNITY_EDITOR) && !UNITY_WEBPLAYER string[] voices = voicesText.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); if (voices.Length % 2 == 0) //if (voices.Length % 3 == 0) { //string id; string name; string culture; Model.Voice newVoice; cachedVoices.Clear(); for (int ii = 0; ii < voices.Length; ii += 2) //for (int ii = 0; ii < voices.Length; ii += 3) { name = voices[ii]; culture = voices[ii + 1]; //id = voices[ii]; //name = voices[ii + 1]; //culture = voices[ii + 2]; name = voices[ii]; culture = voices[ii + 1]; newVoice = new Model.Voice(name, "iOS voice: " + name + " " + culture, culture); //newVoice = new Model.Voice(id, name, "iOS voice: " + name + " " + culture, culture); cachedVoices.Add(newVoice); } if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachedVoices.CTDump()); } //onVoicesReady(); } else { Debug.LogWarning("Voice-string contains wrong number of elements!"); } #endif onVoicesReady(); }
private IEnumerator getVoices() { #if (UNITY_ANDROID || UNITY_EDITOR) && !UNITY_WEBPLAYER yield return(null); if (!isInitialized) { do { yield return(wfs); } while (!(isInitialized = TtsHandler.CallStatic <bool>("isInitalized"))); } try { string[] myStringVoices = TtsHandler.CallStatic <string[]>("GetVoices"); cachedVoices.Clear(); foreach (string voice in myStringVoices) { string[] currentVoiceData = voice.Split(';'); Model.Voice newVoice = new Model.Voice(currentVoiceData[0], "Android voice: " + voice, currentVoiceData[1]); cachedVoices.Add(newVoice); } if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachedVoices.CTDump()); } //onVoicesReady(); } catch (System.Exception ex) { string errorMessage = "Could not get any voices!" + System.Environment.NewLine + ex; Debug.LogError(errorMessage); onErrorInfo(null, errorMessage); } #else yield return(null); #endif onVoicesReady(); }
/// <summary>Receives all voices</summary> /// <param name="voicesText">All voices as text string.</param> public static void SetVoices(string voicesText) { #if UNITY_IOS || UNITY_EDITOR string[] voices = voicesText.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); //if (voices.Length % 2 == 0) if (voices.Length % 3 == 0) { string name; string culture; Model.Voice newVoice; System.Collections.Generic.List <Model.Voice> voicesList = new System.Collections.Generic.List <Model.Voice>(60); //for (int ii = 0; ii < voices.Length; ii += 2) for (int ii = 0; ii < voices.Length; ii += 3) { //name = voices[ii]; //culture = voices[ii + 1]; //newVoice = new Model.Voice(name, "iOS voice: " + name + " " + culture, Util.Helper.AppleVoiceNameToGender(name), "unknown", culture); name = voices[ii + 1]; culture = voices[ii + 2]; newVoice = new Model.Voice(name, "iOS voice: " + name + " " + culture, Util.Helper.AppleVoiceNameToGender(name), "unknown", culture, voices[ii], "Apple"); voicesList.Add(newVoice); } cachediOSVoices = voicesList.OrderBy(s => s.Name).ToList(); if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachediOSVoices.CTDump()); } //onVoicesReady(); } else { Debug.LogWarning("Voice-string contains wrong number of elements!"); } #endif onVoicesReady(); }
/// <summary>Receives all voices</summary> /// <param name="voicesText">All voices as text string.</param> public static void SetVoices(string voicesText) { string[] voices = voicesText.Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); if (voices.Length % 3 == 0) { System.Collections.Generic.List <Model.Voice> voicesList = new System.Collections.Generic.List <Model.Voice>(60); //for (int ii = 0; ii < voices.Length; ii += 2) for (int ii = 0; ii < voices.Length; ii += 3) { var name = voices[ii + 1]; var culture = voices[ii + 2]; var newVoice = new Model.Voice(name, "iOS voice: " + name + " " + culture, Util.Helper.AppleVoiceNameToGender(name), "unknown", culture, voices[ii], "Apple"); voicesList.Add(newVoice); } cachediOSVoices = voicesList.OrderBy(s => s.Name).ToList(); if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachediOSVoices.CTDump()); } } else { Debug.LogWarning("Voice-string contains wrong number of elements!"); } onVoicesReady(); //NativeMethods.FreeMemory(); }
private IEnumerator getVoices() { System.Collections.Generic.List <string[]> serverVoicesResponse = new System.Collections.Generic.List <string[]>(); if (!Util.Helper.isInternetAvailable) { string errorMessage = "Internet is not available - can't use MaryTTS right now!"; Debug.LogError(errorMessage); onErrorInfo(null, errorMessage); } else { using (WWW www = new WWW(uri + "/voices", rawData, headers)) { do { yield return(www); } while (!www.isDone); if (string.IsNullOrEmpty(www.error)) { string[] rawVoices = www.text.Split('\n'); foreach (string rawVoice in rawVoices) { try { if (!string.IsNullOrEmpty(rawVoice)) { string[] newVoice = { rawVoice.Split(' ') [0], rawVoice.Split(' ') [1], rawVoice.Split(' ') [2] }; serverVoicesResponse.Add(newVoice); } } catch (System.Exception ex) { Debug.LogWarning("Problem preparing voice: " + rawVoice + " - " + ex); } } cachedVoices.Clear(); foreach (string[] voice in serverVoicesResponse) { Model.Voice newVoice = new Model.Voice(voice[0], "MaryTTS voice: " + voice[0], voice[2], "unknown", voice[1]); cachedVoices.Add(newVoice); } if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachedVoices.CTDump()); } //onVoicesReady(); } else { string errorMessage = "Could not get the voices: " + www.error; Debug.LogError(errorMessage); onErrorInfo(null, errorMessage); } } onVoicesReady(); } }
private IEnumerator getVoices() { #if (UNITY_STANDALONE_OSX || UNITY_EDITOR) && !UNITY_WEBPLAYER //using (System.Diagnostics.Process voicesProcess = new System.Diagnostics.Process()) //{ System.Diagnostics.Process voicesProcess = new System.Diagnostics.Process(); voicesProcess.StartInfo.FileName = Util.Config.TTS_MACOS; voicesProcess.StartInfo.Arguments = "-v '?'"; voicesProcess.StartInfo.CreateNoWindow = true; voicesProcess.StartInfo.RedirectStandardOutput = true; voicesProcess.StartInfo.RedirectStandardError = true; voicesProcess.StartInfo.UseShellExecute = false; voicesProcess.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8; //* Set your output and error (asynchronous) handlers //voicesProcess.OutputDataReceived += new DataReceivedEventHandler(speakNativeHandler); //voicesProcess.ErrorDataReceived += new DataReceivedEventHandler(ErrorHandler); voicesProcess.Start(); System.Threading.Thread worker = new System.Threading.Thread(() => startProcess(ref voicesProcess, Util.Constants.DEFAULT_TTS_KILL_TIME)); worker.Start(); do { yield return(null); } while (worker.IsAlive || !voicesProcess.HasExited); if (voicesProcess.ExitCode == 0) { cachedVoices.Clear(); using (System.IO.StreamReader streamReader = voicesProcess.StandardOutput) { string reply; while (!streamReader.EndOfStream) { reply = streamReader.ReadLine(); if (!string.IsNullOrEmpty(reply)) { System.Text.RegularExpressions.Match match = sayRegex.Match(reply); if (match.Success) { cachedVoices.Add(new Model.Voice(match.Groups[1].ToString(), match.Groups[3].ToString(), match.Groups[2].ToString().Replace('_', '-'))); } } } } if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachedVoices.CTDump()); } //onVoicesReady(); } else { using (System.IO.StreamReader sr = voicesProcess.StandardError) { string errorMessage = "Could not get any voices: " + voicesProcess.ExitCode + System.Environment.NewLine + sr.ReadToEnd(); Debug.LogError(errorMessage); onErrorInfo(null, errorMessage); } } voicesProcess.Dispose(); //} #else yield return(null); #endif onVoicesReady(); }