alphacep / alphacep/vosk-api

Using a microphone in C#

Open
#986 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
15.1k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Hi! I have a problem with speech recognition through a microphone using NAudio.

```cs
public class VoskDemo {
static VoskRecognizer? rec;
static WaveFileWriter? writer;

private static void WaveInOnDataAvailable(object? sender, WaveInEventArgs e) {
try {
writer.Write(e.Buffer, 0, e.BytesRecorded);

if (rec.AcceptWaveform(e.Buffer, e.BytesRecorded)) Console.WriteLine(rec.Result());
else Console.WriteLine(rec.PartialResult());
} catch { }
}

public static void Main() {
Model model = new Model("model");
rec = new VoskRecognizer(model, 16000f);

WaveInEvent waveIn = new WaveInEvent();
waveIn.WaveFormat = new WaveFormat(16000, 2);
waveIn.DataAvailable += WaveInOnDataAvailable;
waveIn.StartRecording();

writer = new WaveFileWriter(@"D:\test.wav", waveIn.WaveFormat);
while (true) { Thread.Sleep(1000); }
}
}
```

When I write to a file, you can listen to it, but Vosk does not recognize speech

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.