C# Speech Recognition to VTT for movie or video

Viewed 23

I was tiring to get the result with timespan, The mean Ida it's make automatic Speech Recognition to VTT(subtitle) using Google Api, but the problem is given me all result in same time so I' cant know the timespan.

        var speech = SpeechClient.Create();
        var config = new RecognitionConfig
        {
            AudioChannelCount = 2,
            Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
            SampleRateHertz = 44100,
            LanguageCode = LanguageCodes.English.UnitedStates
            
        };
        var audio = RecognitionAudio.FromFile(filepath);
        var response = speech.Recognize(config, audio);

            foreach (var result in response.Results)
            {
                foreach (var alternatives in result.Alternatives)
                {

                    ContextList context = new ContextList();
                    Console.WritLine(alternatives.Transcript);
                }
            }
1 Answers

Edited: Removed java code block.

In the second for-each, you are looping through alternatives, just pick one and continue your operation.

Related