-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Vosk offline speech recognition service #186917
base: master
Are you sure you want to change the base?
Conversation
I just saw #185255, which also packages vosk(-api), but uses upstream Kaldi (with a minimal amount of patches) instead of using alpha cephei’s fork. Is that approach preferable? |
homepage = "https://github.com/alphacep/kaldi/tree/vosk"; | ||
description = "Kaldi fork for the Vosk offline speech recognition API"; | ||
license = licenses.asl20; | ||
platforms = platforms.unix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta.maintainer must be set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it also need to be set for derivations that are not called in all-packages.nix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so if I do nix repl
and try to get the maintainer, I can find you :P
# When updating, always update the git revision (rev) and the version base. | ||
# The version base can be obtained by running src/base/get_version.sh in the kaldi source. | ||
# Only the first three components (major.minor.patch) should be put in here, | ||
# the last one (short git commit hash) will automatically be appended | ||
version_base = "5.5.1046"; | ||
rev = "76cd51d44c0a61e3905c35cadb2ec5f54f3e42d1"; | ||
in | ||
stdenv.mkDerivation rec { | ||
pname = "kaldi"; | ||
version = "${version_base}-${lib.substring 0 5 rev}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# When updating, always update the git revision (rev) and the version base. | |
# The version base can be obtained by running src/base/get_version.sh in the kaldi source. | |
# Only the first three components (major.minor.patch) should be put in here, | |
# the last one (short git commit hash) will automatically be appended | |
version_base = "5.5.1046"; | |
rev = "76cd51d44c0a61e3905c35cadb2ec5f54f3e42d1"; | |
in | |
stdenv.mkDerivation rec { | |
pname = "kaldi"; | |
version = "${version_base}-${lib.substring 0 5 rev}"; | |
in | |
stdenv.mkDerivation rec { | |
pname = "kaldi"; | |
version = "5.5.1046"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That separates the version base from the git revision which makes it more likely that an update forgets to update the version base. Also, I think the comment should stay there because it’s not very intuitive to see what exactly 1046
is and how to get that for different (newer) versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not do this for versions in nixpkgs. Please refer to the contributing guide for details
]; | ||
}); | ||
|
||
# pinned in kaldi/tools/Makefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to pin this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is for upstream to decide. How could this be not pinned in nixpkgs? Every fetcher/FOD needs an output hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the same number as in line 14, is it?
}; | ||
interface = mkOption { | ||
type = types.str; | ||
default = "0.0.0.0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default = "0.0.0.0"; | |
default = "127.0.0.1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.0.0.0
is the upstream default, which is why I copied it. Because there is a firewall active by default on NixOS, there should be no security issues with keeping that default. Also, many other services are listening on all interfaces by default. Is there a reason why this service in particular should only listen on localhost?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a secure default even if firewall is disabled. Otherwise, if we really want this: if config.networking.firewall.enable then "0.0.0.0" else "127.0.0.1"
should be the good option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't do such a confusing conditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Therefore, we should have 127.0.0.1
by default IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I successfully did a test deployment of this module as a transcription service for the Jigasi component of Jitsi Meet! Everything went smoothly on the Vosk side of this deployment so I don't have any changes to suggest here based on that test. The resulting transcription output of a Jitsi Meet conference is kind of buggy, but this is consistent with an existing upstream issue so doesn't seem related to this package/module: alphacep/vosk-server#89
One thing to note for anyone else trying to deploy this is that it uses a lot of memory. I had problem from hitting memory limits on an 8GB VM and had to redeploy on a 16GB one. Looking at performance graphs, it seems to be using max of nearly 10GB for the first ~5mins after the initial deployment (the starting of the vosk service) and then it drops down to a persistent usage of closer to 9GB. If we add higher level documentation of how to use this service with Jigasi and Jitsi Meet then I think it will be worth mentioning this memory usage, but I don't see a requirement for it in this PR.
@cleeyv The high memory usage is definitely something that should be noted, maybe in the description of the |
Looking forward to this! A working offline ASR opens up so many possibilities. |
237c6a2
to
fde0714
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the amazing packaging.
I would need you to move the release notes to 23.05 and some minor things left to be addressed. Other than this, I feel like we can merge it.
version_base = "5.5.1046"; | ||
rev = "76cd51d44c0a61e3905c35cadb2ec5f54f3e42d1"; | ||
in | ||
stdenv.mkDerivation rec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, we might want to override the already existing kaldi
package (either src
or patches
) like in https://github.com/NixOS/nixpkgs/pull/185148/files#diff-a4997bb1585454092e3e7a29bb551970a156f4c7fb1135984c17303027f022e5R10-R32
That way we will not have unnecessary duplication of code that will inevitably get out of sync.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-03-20-nixpkgs-architecture-team-meeting-33/26547/2 |
<listitem> | ||
<para> | ||
<link xlink:href="https://alphacephei.com/vosk/">vosk</link>, | ||
an offline speech recognition service. Available as | ||
<link linkend="opt-services.vosk.enable">services.vosk</link>. | ||
</para> | ||
</listitem> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase and delete this change because the file got deleted
|
||
installPhase = '' | ||
install -D libvosk${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libvosk${stdenv.hostPlatform.extensions.sharedLibrary} | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
''; | |
''; |
Description of changes
This adds Vosk, an offline speech recognition service. It is part of Summer of Nix to allow live transcriptions with Jitsi Meet, for which Vosk is required.
It consists of several parts:
vosk-transcriber
command line tool)Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes