public ITextToSpeechProvider Create(TextToSpeechConfiguration configuration)
            {
                T provider = new T();

                provider.SetConfig(configuration);
                return(provider);
            }
        /// <summary>
        /// Return loaded <see cref="TextToSpeechConfiguration"/>.
        /// </summary>
        public static TextToSpeechConfiguration GetTextToSpeechConfiguration(this BaseRuntimeConfiguration runtimeConfiguration)
        {
            if (textToSpeechConfiguration == null)
            {
                textToSpeechConfiguration = TextToSpeechConfiguration.LoadConfiguration();
            }

            return(textToSpeechConfiguration);
        }
        /// <summary>
        /// Creates an provider with given config.
        /// </summary>
        public ITextToSpeechProvider CreateProvider(TextToSpeechConfiguration configuration)
        {
            if (string.IsNullOrEmpty(configuration.Provider))
            {
                throw new NoConfigurationFoundException($"There is not a valid provider set in '{configuration.GetType().Name}'!");
            }

            if (!registeredProvider.ContainsKey(configuration.Provider))
            {
                throw new NoMatchingProviderFoundException($"No matching provider with name '{configuration.Provider}' found!");
            }

            ITextToSpeechProvider provider = registeredProvider[configuration.Provider].Create(configuration);

            if (configuration.UseStreamingAssetFolder)
            {
                provider = new FileTextToSpeechProvider(provider, configuration);
            }

            return(provider);
        }
        /// <summary>
        /// Returns filename which uniquly identifies the audio by Backend, Language, Voice and also the text.
        /// </summary>
        public static string GetUniqueTextToSpeechFilename(this TextToSpeechConfiguration configuration, string text, string format = "wav")
        {
            string hash = string.Format("{0}_{1}", configuration.Voice, text);

            return(string.Format(@"TTS_{0}_{1}_{2}.{3}", configuration.Provider, LanguageSettings.Instance.ActiveOrDefaultLanguage, GetMd5Hash(hash).Replace("-", ""), format));
        }
예제 #5
0
 /// <inheritdoc />
 public void SetConfig(TextToSpeechConfiguration configuration)
 {
     this.configuration = configuration;
 }
 public FileTextToSpeechProvider(ITextToSpeechProvider fallbackProvider, IAudioConverter audioConverter, TextToSpeechConfiguration configuration)
 {
     Configuration    = configuration;
     AudioConverter   = audioConverter;
     FallbackProvider = fallbackProvider;
 }
 public FileTextToSpeechProvider(ITextToSpeechProvider fallbackProvider, TextToSpeechConfiguration configuration)
 {
     Configuration    = configuration;
     FallbackProvider = fallbackProvider;
 }
 /// <summary>
 /// Loads a new <see cref="TextToSpeechConfiguration"/>
 /// </summary>
 public static void SetTextToSpeechConfiguration(this BaseRuntimeConfiguration runtimeConfiguration,
                                                 TextToSpeechConfiguration ttsConfiguration)
 {
     textToSpeechConfiguration = ttsConfiguration;
 }
        /// <summary>
        ///  Creates an provider, always loads the actual text to speech config to set it up.
        /// </summary>
        public ITextToSpeechProvider CreateProvider()
        {
            TextToSpeechConfiguration ttsConfiguration = TextToSpeechConfiguration.LoadConfiguration();

            return(CreateProvider(ttsConfiguration));
        }