Lurker News
I'd like a home-based voice recognition without some off-site cloud.

I'd like a kind of echo dot like thing running on a set of raspberry pi devices each with a microphone and speaker. Ideally they'd be all over the house. I'm happy if they talk back via wifi to a server in my office for whatever real processing. The server might have 16 cores and 128Gb ram. Might even have two of these if required.
What options do I have? What limits? I'd really prefer answers from people who have experiences with the various options.
If it helps I'm happy to reduce vocabulary to a dictionary of words as long as I can add more words as necessary. Training is also ok. I've already analysed my voice conversations with an echo dot and the vocabulary isn't that large.
Please remember: home use, no off-site clouds. I'm not interested in options involving even a free voice speech-to-text cloud. This eliminates google voice recognition, amazon etc. They are great but out of scope.
So far I've identified CMU Sphinx as a candidate but I'm sure there are others.
Ideas?

Comments (127) 36 threads

romwell4 replies#
TL; DR: Win 10 IoT for RasPi does it.

-----------------
Windows 10 IoT for Raspberry Pi comes with offline speech recognition API.
It was not hard to slap some code together that turns on a light when someone says "banana" at a hackathon.
Sounds like exactly what you need.
>If it helps I'm happy to reduce vocabulary to a dictionary of words
You will do it with an XML grammar file for offline recognition[4].
[1]https://docs.microsoft.com/en-us/windows/iot-core/tutorials/...
[2]https://docs.microsoft.com/en-us/windows/iot-core/extend-you...
Someone's demo project:
[3]https://www.hackster.io/krvarma/rpivoice-051857
[4]https://docs.microsoft.com/en-us/windows/uwp/design/input/sp...

coredog64#
The Microsoft offline speech recognizer is pretty good. I did some work with it many years ago [0]. The only problem we had was with accents: My French co-worker had to use his most obnoxiously over-the-top American accent for reasonable accuracy. ISTR that we could switch to Australian English for the Aussies and Kiwis.

[0] https://github.com/spc-ofp/ObserverLengthSampler

lucb1e2 replies#
This is really interesting, but I have a few questions:

- The setup guide shows a Windows system making a Windows iot version. Can't I just download an iso and flash it to an sdcard with dd? Does it need a license?
- The demo projects show C# and while I can develop in monodevelop, I don't have a Windows to compile it with. Is a C# compiler included in Windows iot's .NET distribution or are there also cross-platform (interpreted) languages that run on Windows iot (e.g. Python3)?

thejosh#
You might be able to use .NET Core which is opensource and can run on Linux/Mac.
Jaruzel#
So, recently I played with Windows10 IoT.

Win10 IoT is written to the SD card, and left to first-boot inside the Pi (this bit takes AGES). While it's doing that you install the Win IoT dashboard toolkit onto your PC (Windows only). The Dashboard will find your Win10 IoT Pi on the network, there's a few demo apps pre installed you can play with. It's a free OS, but you need to pay for a dev licence if you want it to not reboot every 24 hours. (There's also an on screen non-production warning).
Now you fire up Visual Studio, which has gained the ability to build C# apps on ARM. You write a small app, including using the visual form designer, and you debug using the PC based Win IoT emulator, or you deploy it directly (using VS) to the the Pi.
Once you are happy with your app, you have to bake it into a new OS image that gets written to the SD card(s) for proper deployment.
Win10 IoT can only run one app in the foreground. It does not have a classic desktop, which should be fine for embedded or kiosk type applications.
Personally, I found it clunky and slow, even on a fast Pi. There's also a fair amount of restrictions applied to your app (think the same restrictions as an Android or iOS app) so if you are used to your C# app having full (read) access to the machine it's running on, you won't get that on Win IoT.
If you want to develop GUI rich apps on the Pi, there are far better alternatives (Mono, Python/GTK etc. on Raspbian).
This is just my take on Win10 IoT. I'm a Windows guy by profession so I don't have an anti-MS bias here.

rs23296008n1#
Sounds good to me. RasPi are solid performers to us. I'm assuming the XML would need to be updated as the dictionary changes. Sounds easy enough. The loading of languages might get fussy/impossible if I want multiple. A stretch goal is to support multiple languages from the same device.

I'd be hoping I can also load in text-to-speech as well either separately or as part of same application. From what I've read the windows approach to the Pi is more like an appliance. Your application takes over the whole device. This is fine as long as I can load in more functionality to that application.
I need to read more about this.
Thanks for the pointers.

driverdan1 reply#
Does the IoT version track everything you do and cram ads down your throat like the regular version of Win 10?
romwell1 reply#
I don't think this question is in good faith, but the answer is no.
driverdan#
I worded it as an adversarial way but it was a serious question. I'm glad to hear they don't.
dmos62#
The models (`deepspeech-0.6.1-models.tar.gz`) weigh 1.14 gb, if anyone's interested.
kingo552 replies#
Interesting. Are there any projects actively using this today?
dsteinman#
I've been using DeepSpeech to learn to build voice controls for all sorts of things in JavaScript. And I've got a way to connect it to the web so you'll be able write speech recognition enabled web pages using client side JavaScript.

https://github.com/jaxcore/deepspeech-plugin

magicalhippo1 reply#
I had limited luck using the provided language model, but very good results when providing my own. So if you feel the results are poor, try building your own language model.

AFAIK DeepSpeech works by using the neural net to detect characters from speech, and then the language model is used to try to make a sentence out of the character stream, by doing a kind of graph search. Thus if the language model doesn't contain the words you want it to recognize, it'll have a hard time giving good output.
Anyway, I used the following tutorial[1] as a base to build the language model. For the kenlm tools I used Ubuntu WSL, and the generate_trie executable was part of the DeepSpeech native tools package for Windows.
[1]: https://discourse.mozilla.org/t/tutorial-how-i-trained-a-spe...

ghostpepper2 replies#
For a software engineer with no experience in machine learning / AI, what does it mean to build your own language model? Does it require coding? Hundreds of hours of audio data from your own voice? A significant amount of computing power?
magicalhippo1 reply#
The tools available means you only need to provide a list of normal sentences, and they should include the words you'd like it to know about.

For my case I just wanted to train it on like 30 different sentences, that took less than a second. But for a general assistant ala Google Home you'll want a large number of sentences and I hear it can take a while (hour or few?).
Due to using probabilities it will match words in other sentences than what you give it, but from my understanding it will be partial to the ones you feed it if DeepSpeech mis-classifies a character or two.

Continue this thread — 1 reply

magicalhippo#
> Hundreds of hours of audio data from your own voice?

I should clarify this. As I mentioned, training the neural net part requires tons of audio and the corresponding text (and people should totally contribute[1], the resulting data sets are released to the public). The neural net in DeepSpeech is then used on an audio stream and outputs a stream of characters.
Turning that stream of characters into sentences is what the language model is for.
Training the neural net is very data and compute intensive, but fortunately Mozilla provides pre-trained models.
Generating the language model is relatively cheap. And if your target language shares sounds with English, you may get away with using the English-trained neural net but with a non-English language model.
[1]: https://voice.mozilla.org/

hutzlibu#
Here is a paper from a german university, where they tried to adopt DeepSpeech to german:

https://www.researchgate.net/publication/336532830_German_En...
The results are, that adopting works good, but as of writing of the paper somemonths ago, the results were not very good yet. So it takes better trained models for other languages. English seems to be quite good.
What surprised me, is that it works offline very fast even on a rasperry pi!
https://www.hackster.io/dmitrywat/offline-speech-recognition...

albertzeyer1 reply#
Are you searching for a complete solution including NLP and an engine to perform actions? Some of these are already posted, like Home Assistant, and Mycroft.

Sphinx is just for the automatic speech recognition (ASR) part. But there are better solutions for that:
Kaldi (https://kaldi-asr.org/) is probably the most comprehensive ASR solution, which yields very competitive state-of-the-art results.
RASR (https://www-i6.informatik.rwth-aachen.de/rwth-asr/) is for non-commercial use only but otherwise similar as Kaldi.
If you want to use a simpler ASR system, nowadays end-to-end models perform quite well. There are quite a huge number of projects which support these:
RETURNN (https://github.com/rwth-i6/returnn) is non-commercial TF-based. (Disclaimer: I'm one of the main authors.)
Lingvo (https://github.com/tensorflow/lingvo), from Google, TF-based.
ESPnet (https://github.com/espnet/espnet), PyTorch/Chainer.
...

rs23296008n12 replies#
Already got the action engine: all the lights, hvac, tv, calculator, computers, etc are all controllable. None require internet now. Or any kind of location services for that matter.

I really just want the speech-to-text. Ideally I'd also like it to recognise who's talking. But that's a bonus.

thomas5361 reply#
I'll second the recommendation for Kaldi. It's more complicated to get running vs pocketsphinx, but in my experience Kaldi has better accuracy/lower latency in general cases vs pocketsphinx (assuming caveats below).

https://github.com/gooofy/zamia-speech/ has been training good [acoustic] models which are worth looking at (including training with robustness against noise). They've also got lots of code and docker images and documentation.
pocketsphinx isn't actually that bad to use with their latest acoustic models and small vocabularies (so its utility depends on your exact use case). But it's not generally good with far field mics/dsp processed audio, not really good with noise, and in my experiments quite not as fast as Kaldi.
Better/larger language models in my experience make a world of difference (esp in the general vocab case) for improving accuracy for either of kaldi or pocketsphinx. Nobody really seems to talk about this(?), since everyone always uses the news corpus from like the 80s as the default language model.
I haven't really ever gotten the various ~deepspeech systems working, so I can't speak to them.

rs23296008n1#
I'm happy to feed it plenty of voice logs as well as a training corpus as necessary. Sounds like an interesting journey.
arejaytee#
Would love to know more about this and how you've done it
daanzu1 reply#
I develop Kaldi Active Grammar [1], which is mainly intended for use with strict command grammars. Compared to normal language models, these can provide much better accuracy, assuming you can describe (and speak) your command structure exactly. (This is probably more acceptable for a voice assistant for an audience that is more technical.) The grammar can be specified by a FST, or you can use KaldiAG through Dragonfly, which allows you to specify them (and their resultant actions) in Python. However, KaldiAG can also do simple plain dictation if you want.

KaldiAG has an English model available, but other models could be trained. Although you can't just drop in and use a standard Kaldi model with KaldiAG, the modifications required are fairly minimal and don't require any training or modification of its acoustic model. All recognition is performed locally and off line by default, but you can also selectively choose to do some recognition in the cloud, too.
Kaldi generally performs at the state of art. As a hybrid engine, although training can be more complicated, it generally requires far less training data to achieve high accuracy, compared to "end to end" engines.
[1] https://github.com/daanzu/kaldi-active-grammar

daanzu1 reply#
Too late to edit, but I should probably have noted that KaldiAG also would make it easy to define "contexts" when (groups of) commands are active for recognition. For example, if the TV is on, you could have commands for adjusting the volume/etc. But if it is off, those commands are disabled, so they can't be recognized, and further, the engine knows this and can therefore better recognize the other commands that remain active.
barrystaes1 reply#
Could Home Assistant use such commands by running a docker?

Also the video demo is rather impressive, in how accurate (and predictable) it recognises.

daanzu#
I don't know much about Home Assistant, but that certainly should be possible to set up. The KaldiAG API is pretty low level, but basically: you define a set of rules, and send in audio data, along with a bit mask of which rules are active at the beginning of each utterance, and receive back the recognized rule and text. The easy solution is probably to go through Dragonfly, which makes it easy to define the rules, contexts, and actions. It might be a little hacky to do, but you should be able to wire it up with Home Assistant somehow.

Although I mainly use it for computer control as demonstrated in the video, I do have many commands akin to home automation, like adjusting the lights, HVAC, etc.

Load more comments