Exemplo n.º 1
0
    public static void DemoSpeaker(Model model)
    {
        // Output speakers
        SpkModel       spkModel = new SpkModel("model-spk");
        VoskRecognizer rec      = new VoskRecognizer(model, 16000.0f);

        rec.SetSpkModel(spkModel);

        using (Stream source = File.OpenRead("test.wav")) {
            byte[] buffer = new byte[4096];
            int    bytesRead;
            while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                if (rec.AcceptWaveform(buffer, bytesRead))
                {
                    Console.WriteLine(rec.Result());
                }
                else
                {
                    Console.WriteLine(rec.PartialResult());
                }
            }
        }
        Console.WriteLine(rec.FinalResult());
    }