如何访问Google Speech API中填充的Word集合?

时间:2019-06-20 01:11:20

标签: c# google-speech-api

如何访问Google Speech API中填充的Word集合?

在Windows 10上的Visual Studio中使用C#的.NET Console项目中,我有以下代码:

static void Main(string[] args)
{
    Console.WriteLine("Hello World!");

    var speech = SpeechClient.Create();
    var response = speech.Recognize(new RecognitionConfig()
    {
        Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
        SampleRateHertz = 44100,
        AudioChannelCount = 2,
        LanguageCode = "en",
    }, RecognitionAudio.FromFile("C:\\Users\\dbrow_000\\source\\repos\\DotNetConsoleAppSpeechToText01\\DotNetConsoleAppSpeechToText01\\audio.flac"));
    foreach (var result in response.Results)
    {
        foreach (var alternative in result.Alternatives)
        {
            Console.WriteLine(alternative.Transcript);
        }
    }

    Console.WriteLine("**********");

    foreach (var result in response.Results)
    {
        foreach (var alternative in result.Alternatives)
        {
            foreach (var word in alternative.Words)
            {
                Console.WriteLine(word.ToString() + " - " + word.EndTime);
            }
        }
    }

命令行中的输出为:

Hello World!
The Book of Mormon and the account written by the hand of Mormon upon plates taken from the plates of Nephi it is an abridgment of the record of the people of Nephi and also of the lamanites written to the lamanites who are a remnant of the House of Israel and also to Jew and Gentile written by William commandment and also by the spirit of Prophecy and the Revelation and sealed up and hit up under the Lord but they might not be destroyed to come forth by the gift and power of God under the interpretation they're all sealed by the ham tomorrow night
**********

如您所见,没有单词和结束时间值被打印出来。

我需要做什么来访问单词?

0 个答案:

没有答案
相关问题