There are a bunch of good libraries that work offline out there for speech recognition -- CMUSphinx[0] has been around a long time and work seems to have shifted a little bit to Kaldi[1] and Vosk[2] (?). Julius is still going strong as well[3].
CMUSphinx and Julius have been around for ~10+ years at this point.
[EDIT] - there's even a useful Quora post[4]
[0]: https://cmusphinx.github.io/
[1]: https://www.kaldi-asr.org/doc/about.html
[2]: https://github.com/alphacep/vosk-server
[3]: https://github.com/julius-speech/julius
[4]: https://www.quora.com/Are-there-any-open-source-APIs-for-spe...