예제 #1
0
        // The voice synthesis APIs are now only availabel in DC EastUS
        private static void VoiceSynthsisAPIs()
        {
            // Will uplad the locale input text file to this azure storage blob temporary, this can be deleted after the API complete.
            string azureStorageConnectionString = "Your azure storage connection string";

            string endpoint        = "https://eastus.cris.ai/";
            string ibizaStsUrl     = "https://eastus.api.cognitive.microsoft.com/sts/v1.0/issueToken";
            string subscriptionKey = "Your SubscriptionKey";

            CustomVoiceAPI customVoiceAPI = new CustomVoiceAPI(endpoint, ibizaStsUrl, subscriptionKey);

            // Get available voices list
            var voices = customVoiceAPI.GetVoices();

            // Submit a voice synthesis request
            const string Name        = "Simple neural TTS batch synthesis";
            const string Description = "Simple neural TTS batch synthesis description";

            const string Locale             = "en-US";
            const string LocalInputTextFile = @"TestData\en-US_small.txt";
            const string VoiceName          = "TargetVoiceName";

            var voice = voices.Where(m => m.Locale == Locale && m.Name.Contains(VoiceName)).FirstOrDefault();

            if (voice == null)
            {
                Console.WriteLine($"Does not have a available voice for local : {Locale} and name {VoiceName}");
                return;
            }

            customVoiceAPI.CreateBatchSynthesis(Name, Description, Locale, LocalInputTextFile, voice.Id, azureStorageConnectionString);

            // Get submitted synthesis request list and update a submitted synthesis request
            var syntheses = customVoiceAPI.GetSyntheses();

            var synthesis = syntheses.FirstOrDefault();

            if (synthesis != null)
            {
                customVoiceAPI.UpdateSynthesis(synthesis.Id, "Updated Name", "Updated Desc");
            }

            // Delete all pre-existing completed synthesis. If synthesis are still running or not started, they will not be deleted
            syntheses = customVoiceAPI.GetSyntheses();
            foreach (var item in syntheses)
            {
                // delete a synthesis
                customVoiceAPI.DeleteSynthesis(item.Id);
            }
        }
예제 #2
0
        private static Guid GetVoiceId(CustomVoiceAPI api, string locale, string voiceName, bool publicVoice)
        {
            // Get available voices list
            var   voices = api.GetVoices();
            Voice voice  = null;

            if (publicVoice)
            {
                voice = voices.Where(m => m.Locale == locale && m.Name.Contains(voiceName) && m.IsPublicVoice).FirstOrDefault();
            }
            else
            {
                voice = voices.Where(m => m.Locale == locale && m.Name.Contains(voiceName)).FirstOrDefault();
            }
            if (voice == null)
            {
                Console.WriteLine($"Does not have a available voice for locale : {locale} , name : {voiceName}, public : {publicVoice}");
                return(Guid.Empty);
            }
            return(voice.Id);
        }