M doc/sprec.1.scd => doc/sprec.1.scd +8 -4
@@ 20,10 20,6 @@ sprec(1)
*-h*, *--help*
Print help and exit.
-*--model=*_DIRECTORY_
- Specify the speech recognition model. The default is
- */usr/share/vosk-models/small-en-us*.
-
*--partial*
Also print intermediate results.
@@ 36,6 32,14 @@ sprec(1)
*--version*
Print the version and exit.
+# MODEL
+
+The speech recognition model can be specified with
+the *SPREC_MODEL* environment variable. The default is
+*/usr/share/vosk-models/small-en-us*. *sprec* should work well
+with possibly all of the \**-small* and \**-lgraph* models from
+*https://alphacephei.com/vosk/models*.
+
# AUDIO
The correct audio format depends on the model, but possibly all the Vosk
M sprec.go => sprec.go +7 -10
@@ 18,7 18,6 @@ var usage = `Usage: sprec [OPTIONS] < audio
sprec reads audio from stdin and prints speech recognition results.
--alts NUM Specify the max number of alternative results.
---model DIRECTORY Specify the speech recognition model.
--partial Also print intermediate results.
--phrase-file FILE Limit the vocab to keyphrases in a file.
--version Print the version and exit.
@@ 73,12 72,11 @@ func printResults(results []vox.Result) {
}
func mainish() int {
- opts := struct {
+ var opts struct {
Alts int
- Model string
Partial bool
PhraseFile string
- }{Model: "/usr/share/vosk-models/small-en-us"}
+ }
{
o := opt.NewOptSet()
@@ 96,11 94,6 @@ func mainish() int {
})
o.Alias("h", "help")
- o.Func("model", func(s string) error {
- opts.Model = s
- return nil
- })
-
o.BoolFunc("partial", func(b bool) error {
opts.Partial = b
return nil
@@ 127,7 120,11 @@ func mainish() int {
}
}
- model, err := vox.NewModel(opts.Model)
+ m := os.Getenv("SPREC_MODEL")
+ if m == "" {
+ m = "/usr/share/vosk-models/small-en-us"
+ }
+ model, err := vox.NewModel(m)
if err != nil {
inform(err.Error())
return 1