Skip to content
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

ibus-engines.stt-vosk: init at 0.2.0 #185255

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions pkgs/development/libraries/gst-vosk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchurl
, meson
, ninja
, pkg-config
, gst_all_1
, vosk-api
}:

stdenv.mkDerivation rec {
pname = "gst-vosk";
version = "0.1.0";

src = fetchFromGitHub {
owner = "PhilippeRo";
repo = "gst-vosk";
rev = version;
sha256 = "Ez0TS/WMexj45h1rpvrNAsl6ZKPuwsG9bqZBxrBE4jo=";
};

patches = [
./unvendor-vosk.patch
];

nativeBuildInputs = [
meson
ninja
pkg-config
];

buildInputs = [
gst_all_1.gstreamer
vosk-api
];

meta = with lib; {
description = "GStreamer plug-in for VOSK";
homepage = "https://github.com/PhilippeRo/gst-vosk";
license = licenses.gpl2Plus;
maintainers = with maintainers; [ jtojnar ];
platforms = vosk-api.meta.platforms;
};
}
49 changes: 49 additions & 0 deletions pkgs/development/libraries/gst-vosk/unvendor-vosk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
diff --git a/meson.build b/meson.build
index 866d5b3..f46f94f 100644
--- a/meson.build
+++ b/meson.build
@@ -42,5 +42,4 @@ configure_file(
)

subdir('src')
-subdir('vosk')
subdir('po')
diff --git a/src/gstvosk.c b/src/gstvosk.c
index ffc9340..47a5cb9 100644
--- a/src/gstvosk.c
+++ b/src/gstvosk.c
@@ -25,7 +25,6 @@
#include <gst/gst.h>

#include "gstvosk.h"
-#include "vosk-api.h"
#include "../gst-vosk-config.h"

GST_DEBUG_CATEGORY_STATIC (gst_vosk_debug);
diff --git a/src/gstvosk.h b/src/gstvosk.h
index 855e5c1..b7cbbff 100644
--- a/src/gstvosk.h
+++ b/src/gstvosk.h
@@ -23,7 +23,7 @@
#include <gio/gio.h>
#include <gst/gst.h>

-#include "vosk-api.h"
+#include "vosk_api.h"

G_BEGIN_DECLS

diff --git a/src/meson.build b/src/meson.build
index a1e5ea0..df0da58 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -4,8 +4,7 @@ gst_vosk_sources = [

vosk_libdir = meson.project_source_root() / 'vosk'
vosk_dep = declare_dependency(
- dependencies : cc.find_library('vosk', dirs : vosk_libdir),
- include_directories : include_directories('../vosk/'),
+ dependencies : cc.find_library('vosk'),
)

gstvosk = library('gstvosk',
10 changes: 5 additions & 5 deletions pkgs/tools/audio/kaldi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ let
in
stdenv.mkDerivation {
pname = "kaldi";
version = "2021-12-03";
version = "2022-07-20";

src = fetchFromGitHub {
owner = "kaldi-asr";
repo = "kaldi";
rev = "2b016ab8cb018e031ab3bf01ec36cc2950c7e509";
sha256 = "sha256-R8CrY7cwU5XfeGEgeFuZ0ApsEcEmWN/lrZaCjz85tyk=";
rev = "9af2c5c16389e141f527ebde7ee432a0c1df9fb9";
sha256 = "sha256-+gX9cm5iUmeuufofxB6VZpjDjPp7+Lr/bhCSRypB0cU=";
};

cmakeFlags = [
"-DKALDI_BUILD_TEST=off"
"-DBUILD_SHARED_LIBS=on"
"-DLAPACK_LIBRARIES=-llapack"
"-DBLAS_LIBRARIES=-lblas"
];

enableParallelBuilding = true;

preConfigure = ''
mkdir bin
cat > bin/git <<'EOF'
Expand Down
61 changes: 61 additions & 0 deletions pkgs/tools/audio/vosk-api/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{ stdenv
, fetchFromGitHub
, fetchpatch
, cmake
, kaldi
, openblas
, python3
, lib
}:

stdenv.mkDerivation rec {
name = "vosk-api";
version = "0.3.43";

src = fetchFromGitHub {
owner = "alphacep";
repo = "vosk-api";
rev = "v${version}";
sha256 = "SbCZx+G5q/W7CBVbmGZYf2ubhUJXtSTzaFAwQEJEt3Y=";
};

nativeBuildInputs = [
cmake
];

buildInputs = [
(kaldi.overrideAttrs (attrs: {
patches = attrs.patches or [ ] ++ [
# Vosk patches: https://github.com/kaldi-asr/kaldi/compare/master...alphacep:kaldi:vosk
# https://github.com/alphacep/vosk-api/issues/1082
(fetchpatch {
url = "https://github.com/kaldi-asr/kaldi/commit/1612ee9afa41e141061e53615fffa2a7cfdf94ac.patch";
sha256 = "owqmOIhh4ylR2mOBc9fxV0yrMVYtV4bobnvl2Quis2A=";
})
(fetchpatch {
url = "https://github.com/kaldi-asr/kaldi/commit/8f96991720beb0685fba15ffcea9ac89d33b8d23.patch";
sha256 = "IyFwezIdpfvvSRThJacb4spy9EZVDsRzvJlmglB/caw=";
})
];
}))
openblas
];

cmakeFlags = [
"-DBUILD_SHARED_LIBS:BOOL=on"
];

passthru = {
tests = {
python = python3.pkgs.vosk-python;
};
};

meta = with lib; {
description = "Offline speech recognition API";
homepage = "https://github.com/alphacep/vosk-api";
license = licenses.asl20;
maintainers = with maintainers; [ jtojnar ];
platforms = platforms.unix;
};
}
69 changes: 69 additions & 0 deletions pkgs/tools/inputmethods/ibus-engines/ibus-stt-vosk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ stdenv
, lib
, fetchFromGitHub
, meson
, ninja
, pkg-config
, gst_all_1
, gst-vosk
, ibus
, pango
, gtk4
, libadwaita
, python3
, gobject-introspection
, wrapGAppsHook4
, desktop-file-utils
}:

stdenv.mkDerivation rec {
pname = "ibus-stt-vosk";
version = "0.2.0";

src = fetchFromGitHub {
owner = "PhilippeRo";
repo = "IBus-Speech-To-Text";
rev = version;
sha256 = "K3l9glsnaX0G/O/kXUlh6KpQ/dr2mipRqSOdjOhoROM=";
};

nativeBuildInputs = [
meson
ninja
pkg-config
gobject-introspection # for setup hook
wrapGAppsHook4
desktop-file-utils
];

buildInputs = [
gst_all_1.gstreamer
gst_all_1.gst-plugins-base # for audioconvert
gst_all_1.gst-plugins-good # for pulsesrc
gst-vosk
ibus
pango
gtk4
libadwaita
(python3.withPackages (ps: [
ps.pygobject3
ps.gst-python
ps.babel
(ps.toPythonModule ibus)
]))
];

postPatch = ''
substituteInPlace engine/meson.build --replace 'meson.project_license()' 'meson.project_license()[0]'
patchShebangs build-aux/meson_post_install.py
'';

meta = with lib; {
isIbusEngine = true;
description = "Speech to text IBus engine using VOSK";
homepage = "https://github.com/PhilippeRo/IBus-Speech-To-Text";
license = licenses.gpl3Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ jtojnar ];
};
}
6 changes: 6 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,8 @@ with pkgs;

vopono = callPackage ../tools/networking/vopono { };

vosk-api = callPackage ../tools/audio/vosk-api { };

winbox = callPackage ../tools/admin/winbox {
wine = wineWowPackages.staging;
use64 = true;
Expand Down Expand Up @@ -5111,6 +5113,8 @@ with pkgs;

rime = callPackage ../tools/inputmethods/ibus-engines/ibus-rime { };

stt-vosk = callPackage ../tools/inputmethods/ibus-engines/ibus-stt-vosk { };

table = callPackage ../tools/inputmethods/ibus-engines/ibus-table { };

table-chinese = callPackage ../tools/inputmethods/ibus-engines/ibus-table-chinese {
Expand Down Expand Up @@ -18106,6 +18110,8 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) AudioToolbox AVFoundation Cocoa CoreFoundation CoreMedia CoreServices CoreVideo DiskArbitration Foundation IOKit MediaToolbox OpenGL VideoToolbox;
});

gst-vosk = callPackage ../development/libraries/gst-vosk { };

gusb = callPackage ../development/libraries/gusb { };

qt-mobility = callPackage ../development/libraries/qt-mobility {};
Expand Down