public override IEnumerator Generate(Model.Wrapper wrapper) { #if UNITY_WSA || UNITY_EDITOR if (wrapper == null) { Debug.LogWarning("'wrapper' is null!"); } else { if (string.IsNullOrEmpty(wrapper.Text)) { Debug.LogWarning("'wrapper.Text' is null or empty: " + wrapper); yield return(null); } else { do { yield return(null); } while (!isInitialized); string voiceName = getVoiceName(wrapper); string outputFile = getOutputFile(wrapper.Uid, true); ttsHandler.SynthesizeToFile(prepareText(wrapper), Application.persistentDataPath.Replace('/', '\\'), Util.Constants.AUDIOFILE_PREFIX + wrapper.Uid + AudioFileExtension, voiceName); silence = false; onSpeakAudioGenerationStart(wrapper); do { yield return(wfs); } while (!silence && ttsHandler.isBusy); //Debug.Log("FILE: " + "file://" + outputFile + "/" + wrapper.Uid + extension); processAudioFile(wrapper, outputFile); } } #else yield return(null); #endif }
public override IEnumerator Generate(Model.Wrapper wrapper) { if (wrapper == null) { Debug.LogWarning("'wrapper' is null!"); } else { if (string.IsNullOrEmpty(wrapper.Text)) { Debug.LogWarning("'wrapper.Text' is null or empty: " + wrapper); yield return(null); } else { yield return(null); //return to the main process (uid) #if !UNITY_EDITOR ttsHandler.isBusy = true; string voiceName = getVoiceName(wrapper); string outputFile = getOutputFile(wrapper.Uid, true); string path = Application.persistentDataPath.Replace('/', '\\'); //ttsHandler.SynthesizeToFile(prepareText(wrapper), Application.persistentDataPath.Replace('/', '\\'), Util.Constants.AUDIOFILE_PREFIX + wrapper.Uid + AudioFileExtension, voiceName); UnityEngine.WSA.Application.InvokeOnUIThread(() => { ttsHandler.SynthesizeToFile(prepareText(wrapper), path, Util.Constants.AUDIOFILE_PREFIX + wrapper.Uid + AudioFileExtension, voiceName); }, false); //UnityEngine.WSA.Application.InvokeOnAppThread(() => { ttsHandler.SynthesizeToFile(prepareText(wrapper), path, Util.Constants.AUDIOFILE_PREFIX + wrapper.Uid + AudioFileExtension, voiceName); }, false); silence = false; onSpeakAudioGenerationStart(wrapper); do { yield return(null); } while (!silence && ttsHandler.isBusy); //Debug.Log("FILE: " + "file://" + outputFile + "/" + wrapper.Uid + extension); processAudioFile(wrapper, outputFile); #endif } } }
public override IEnumerator Generate(Model.Wrapper wrapper) { #if (UNITY_WSA || UNITY_EDITOR) && !UNITY_WEBPLAYER if (wrapper == null) { Debug.LogWarning("'wrapper' is null!"); } else { if (string.IsNullOrEmpty(wrapper.Text)) { Debug.LogWarning("'Text' is null or empty: " + wrapper); yield return(null); } else { yield return(null); //return to the main process (uid) while (!isInitialized) { yield return(null); } string voiceName = getVoiceName(wrapper); string outputFile = Application.persistentDataPath; ttsHandler.SynthesizeToFile(wrapper.Text, outputFile.Replace('/', '\\'), wrapper.Uid + extension, voiceName); silence = false; onSpeakAudioGenerationStart(wrapper); do { yield return(wfs); } while (!silence && ttsHandler.IsBusy()); //Debug.Log("FILE: " + "file://" + outputFile + "/" + wrapper.Uid + extension); if (Util.Config.DEBUG) { Debug.Log("Text generated: " + wrapper.Text); } if (!string.IsNullOrEmpty(wrapper.OutputFile)) { wrapper.OutputFile += AudioFileExtension; fileCopy(outputFile, wrapper.OutputFile, Util.Config.AUDIOFILE_AUTOMATIC_DELETE); } if (Util.Config.AUDIOFILE_AUTOMATIC_DELETE) { if (System.IO.File.Exists(outputFile)) { try { System.IO.File.Delete(outputFile); } catch (System.Exception ex) { string errorMessage = "Could not delete file '" + outputFile + "'!" + System.Environment.NewLine + ex; Debug.LogError(errorMessage); onErrorInfo(wrapper, errorMessage); } } } else { if (string.IsNullOrEmpty(wrapper.OutputFile)) { wrapper.OutputFile = outputFile; } } onSpeakAudioGenerationComplete(wrapper); } } #else yield return(null); #endif }