private async void InitializeAudioClip() { if (Application.isPlaying == false) { return; } if (Text == null) { Debug.LogWarning("No text provided"); return; } if (string.IsNullOrEmpty(Text.Value)) { Debug.LogWarning($"No text provided for key '{Text.Key}'"); return; } isLoading = true; try { TextToSpeechConfiguration ttsConfiguration = RuntimeConfigurator.Configuration.GetTextToSpeechConfiguration(); ITextToSpeechProvider provider = TextToSpeechProviderFactory.Instance.CreateProvider(ttsConfiguration); AudioClip = await provider.ConvertTextToSpeech(Text.Value); } catch (Exception exception) { Debug.LogWarning(exception.Message); } isLoading = false; }
private void OnEnable() { textToSpeechConfiguration = (TextToSpeechConfiguration)target; providers = ReflectionUtils.GetConcreteImplementationsOf <ITextToSpeechProvider>().ToList().Where(type => type != typeof(FileTextToSpeechProvider)).Select(type => type.Name).ToArray(); lastProviderSelectedIndex = providersIndex = string.IsNullOrEmpty(textToSpeechConfiguration.Provider) ? Array.IndexOf(providers, nameof(MicrosoftSapiTextToSpeechProvider)) : Array.IndexOf(providers, textToSpeechConfiguration.Provider); textToSpeechConfiguration.Provider = providers[providersIndex]; }
public void SetUp() { _speechLibraryMock = new Mock <ISpeechLibrary>(); _configurationManagerMock = new Mock <IConfigurationManager <TextToSpeechConfiguration> >(); _textToSpeechNotifier = new TextToSpeechNotifier(_speechLibraryMock.Object, _configurationManagerMock.Object); textToSpeechConfiguration = new TextToSpeechConfiguration(); textToSpeechConfiguration.AddNetworkIdToNameMap(requestorId, requestorName); }
/// <inheritdoc/> public void OnGUI(string searchContext) { GUILayout.Label("Configuration for your Text to Speech provider.", CreatorEditorStyles.ApplyPadding(CreatorEditorStyles.Label, 0)); GUILayout.Space(8); TextToSpeechConfiguration config = TextToSpeechConfiguration.Instance; Editor.CreateEditor(config, typeof(TextToSpeechConfigurationEditor)).OnInspectorGUI(); GUILayout.Space(8); CreatorGUILayout.DrawLink("Need Help? Visit our documentation", "https://developers.innoactive.de/documentation/creator/latest/articles/developer/12-text-to-speech.html", 0); }