public void AnnotateVideo()
        {
            // Sample: AnnotateVideo
            // Additional: AnnotateVideo(string, IEnumerable<Feature>, CallSettings)
            VideoIntelligenceServiceClient client = VideoIntelligenceServiceClient.Create();
            Operation <AnnotateVideoResponse, AnnotateVideoProgress> operation = client.AnnotateVideo(
                "gs://cloud-samples-data/video/gbikes_dinosaur.mp4",
                new[] { Feature.LabelDetection });
            Operation <AnnotateVideoResponse, AnnotateVideoProgress> resultOperation = operation.PollUntilCompleted();

            VideoAnnotationResults result = resultOperation.Result.AnnotationResults[0];

            foreach (LabelAnnotation label in result.ShotLabelAnnotations)
            {
                Console.WriteLine($"Label entity: {label.Entity.Description}");
                Console.WriteLine("Frames:");
                foreach (LabelSegment segment in label.Segments)
                {
                    Console.WriteLine($"  {segment.Segment.StartTimeOffset}-{segment.Segment.EndTimeOffset}: {segment.Confidence}");
                }
            }
            // End sample

            Assert.Contains(result.ShotLabelAnnotations, lab => lab.Entity.Description == "dinosaur");
        }
        public void ThrowOnError_Error()
        {
            var results = new VideoAnnotationResults {
                Error = new Rpc.Status {
                    Message = "Bang"
                }
            };
            var exception = Assert.Throws <AnnotateVideoException>(() => results.ThrowOnError());

            Assert.Equal("Bang", exception.Message);
            Assert.Same(results, exception.Response);
        }
        public void ThrowOnError_NoError()
        {
            var results = new VideoAnnotationResults
            {
                ShotLabelAnnotations =
                {
                    new LabelAnnotation
                    {
                        Entity = new Entity{
                            Description = "X"
                        }
                    }
                }
            };

            Assert.Same(results, results.ThrowOnError());
        }
        public void SpeechTranscription()
        {
            // Sample: SpeechTranscription
            VideoIntelligenceServiceClient client  = VideoIntelligenceServiceClient.Create();
            AnnotateVideoRequest           request = new AnnotateVideoRequest
            {
                InputUri     = "gs://cloud-samples-data/video/googlework_short.mp4",
                Features     = { Feature.SpeechTranscription },
                VideoContext = new VideoContext
                {
                    SpeechTranscriptionConfig = new SpeechTranscriptionConfig
                    {
                        LanguageCode = "en-US",
                        EnableAutomaticPunctuation = true
                    }
                }
            };
            Operation <AnnotateVideoResponse, AnnotateVideoProgress> operation       = client.AnnotateVideo(request);
            Operation <AnnotateVideoResponse, AnnotateVideoProgress> resultOperation = operation.PollUntilCompleted();

            VideoAnnotationResults result = resultOperation.Result.AnnotationResults[0];

            foreach (SpeechTranscription transcription in result.SpeechTranscriptions)
            {
                Console.WriteLine($"Language code: {transcription.LanguageCode}");
                Console.WriteLine("Alternatives:");
                foreach (SpeechRecognitionAlternative alternative in transcription.Alternatives)
                {
                    Console.WriteLine($"({alternative.Confidence}) {alternative.Transcript}");
                }
            }
            // End sample

            IEnumerable <string> allTranscripts = result.SpeechTranscriptions
                                                  .SelectMany(st => st.Alternatives)
                                                  .Select(alt => alt.Transcript);

            Assert.Contains(allTranscripts, t => t.Contains("Paris is special because"));
        }