1

I was trying to get the result with timespan, the main idea is to make automatic Speech Recognition to VTT(subtitle) using Google API, but the problem is it's giving me all results at the same time so I can't 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);
                }
            }
Edson Passos
  • 117
  • 10

1 Answers1

-1

Edited: Removed java code block.

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

ozan.yarci
  • 89
  • 1
  • 5
  • This appears to be Java, not C#. I can't imagine that spinning a thread with a sleep is good practice in Java. It's not in C#. – Enigmativity Sep 24 '22 at 22:59