Esempio n. 1
0
        static void Main(string[] args)
        {
            ConfigWrapper config = new ConfigWrapper(new ConfigurationBuilder()
                                                     .SetBasePath(Directory.GetCurrentDirectory())
                                                     .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                                     .AddEnvironmentVariables()
                                                     .Build());
            TextModerator textModerator = new TextModerator(config);

            string videoPath = "https://shigeyfampdemo.azurewebsites.net/videos/ignite.mp4";

            try
            {
                Task <TextModerationResult> task1  = textModerator.ModerateVideo(videoPath);
                TextModerationResult        result = task1.Result;
                Task <string> task2 = WebVttParser.LoadWebVtt(result.StreamingUrlDetails.VttUrl);
                result.WebVtt = task2.Result;
                List <CaptionTextModerationResult>         captionTextResults = WebVttParser.ParseWebVtt(result.WebVtt);
                Task <List <CaptionTextModerationResult> > task3 = textModerator.TextScreen(captionTextResults);
                result.CaptionTextResults = task3.Result;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: ", e.ToString());
            }
            Console.WriteLine("Visual Modeation has finished.");
            Console.WriteLine("Press any key to stop...");
            Console.ReadKey();
        }
Esempio n. 2
0
        private static async Task <TextModerationResult> ProcessTextModeration(string webVttUrl)
        {
            Console.WriteLine("[Content Moderator] Text moderation process started...");
            TextModerationResult result = new TextModerationResult();

            try
            {
                string webVttString = await WebVttParser.LoadWebVtt(webVttUrl);

                result.webVtt = webVttString;
                List <CaptionTextModerationResult> captionTextResults = WebVttParser.ParseWebVtt(webVttString);
                result.captionTextResults = await textModerator.TextScreen(captionTextResults);
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[Content Moderator] Text moderation process failed. Error: ", e.ToString());
                Console.ForegroundColor = ConsoleColor.White;
            }

            Console.WriteLine("[Content Moderator] Text moderation process completed...");
            return(result);
        }