Skip to content
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
63 changes: 63 additions & 0 deletions pkgs/development/libraries/gst-deepspeech/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchurl
, autoreconfHook
, pkg-config
, gst_all_1
, stt
, stt-models
, unstableGitUpdater
}:

stdenv.mkDerivation rec {
pname = "gst-deepspeech";
version = "unstable-2021-04-08";

outputs = [ "out" "dev" ];

src = fetchFromGitHub {
owner = "Elleo";
repo = "gst-deepspeech";
rev = "2aef372a7a1064c90ffb70c12721657bf92fca66";
sha256 = "9XGSUYV6jRMsMSA8TO7y7u9T7NihB4azzKJfZ/OPcLI=";
};

nativeBuildInputs = [
autoreconfHook
pkg-config
];

buildInputs = [
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
stt
];

postPatch = ''
# https://github.com/Elleo/gst-deepspeech/pull/20
substituteInPlace src/gstdeepspeech.cc \
--replace "/usr/share/deepspeech/models/deepspeech-0.9.3-models.pbmm" "${stt-models.english.tflite}" \
--replace "/usr/share/deepspeech/models/deepspeech-0.9.3-models.scorer" "${stt-models.english.scorer}" \
--replace "#include <deepspeech.h>" "" \
--replace "DS_" "STT_"
substituteInPlace src/gstdeepspeech.h \
--replace '#include "deepspeech.h"' "#include <coqui-stt.h>"
substituteInPlace src/Makefile.am \
--replace "-ldeepspeech" "-lstt"
'';

passthru = {
updateScript = unstableGitUpdater {
url = "${src.meta.homepage}.git";
};
};

meta = {
description = "GStreamer plug-in for STT";
homepage = "https://github.com/Elleo/gst-deepspeech";
license = lib.licenses.lgpl2Plus;
maintainers = with lib.maintainers; [ jtojnar ];
platforms = stt.meta.platforms;
};
}
22 changes: 18 additions & 4 deletions pkgs/tools/audio/stt/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{ stdenv, lib, fetchurl, autoPatchelfHook }:
{ stdenv
, lib
, fetchurl
, autoPatchelfHook
, xz
, bzip2
}:

stdenv.mkDerivation rec {
pname = "stt";
version = "0.9.3";
version = "1.3.0";

src = fetchurl {
url = "https://github.com/coqui-ai/STT/releases/download/v${version}/native_client.tf.Linux.tar.xz";
sha256 = "0axwys8vis4f0m7d1i2r3dfqlc8p3yj2nisvc7pdi5qs741xgy8w";
url = "https://github.com/coqui-ai/STT/releases/download/v${version}/native_client.tflite.Linux.tar.xz";
sha256 = "JsMrSNE0KlKpI998wPY6dMTyTggRtqu4JmucBmgirNs=";
};
setSourceRoot = "sourceRoot=`pwd`";

Expand All @@ -16,12 +22,20 @@ stdenv.mkDerivation rec {

buildInputs = [
stdenv.cc.cc.lib
xz # for lzma
bzip2
];

installPhase = ''
runHook preInstall

install -D stt $out/bin/stt
install -D coqui-stt.h $out/include/coqui-stt.h
install -D libsox.so.3 $out/lib/libsox.so.3
install -D libkenlm.so $out/lib/libkenlm.so
install -D libstt.so $out/lib/libstt.so

runHook postInstall
'';

meta = with lib; {
Expand Down
18 changes: 18 additions & 0 deletions pkgs/tools/audio/stt/models.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
fetchurl,
}:

{
english = {
# https://coqui.ai/english/coqui/v0.9.3
scorer = fetchurl {
url = "https://coqui.gateway.scarf.sh/english/coqui/v0.9.3/coqui-stt-0.9.3-models.scorer";
sha256 = "0M+SarnKtUqKfXAAO5MbLWLr2RBe05LR7JyEACmGd5k=";
};

tflite = fetchurl {
url = "https://coqui.gateway.scarf.sh/english/coqui/v0.9.3/model.tflite";
sha256 = "Coj5j/Fcm/dgv32gNbna+uJA5+sACvN2+H4FKq4zEgM=";
};
};
}
61 changes: 61 additions & 0 deletions pkgs/tools/inputmethods/ibus-engines/ibus-stt/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{ stdenv
, lib
, fetchFromGitHub
, autoreconfHook
, pkg-config
, gst_all_1
, gst-deepspeech
, ibus
, pango
, python3
, gobject-introspection
, wrapGAppsHook
, unstableGitUpdater
}:

stdenv.mkDerivation rec {
pname = "ibus-deepspeech";
version = "unstable-2017-12-30";

src = fetchFromGitHub {
owner = "Elleo";
repo = "ibus-deepspeech";
rev = "3ea7c537e60e3ff66c566355c2b365febc91a91a";
sha256 = "51rSPqen40drSfB60q/unc2EbX5lgJnPCIRoH4qq/AM=";
};

nativeBuildInputs = [
autoreconfHook
pkg-config
gobject-introspection # for setup hook
wrapGAppsHook
];

buildInputs = [
gst_all_1.gstreamer
gst_all_1.gst-plugins-good
gst-deepspeech
ibus
pango
(python3.withPackages (ps: [
ps.pygobject3
ps.gst-python
(ps.toPythonModule ibus)
]))
];

passthru = {
updateScript = unstableGitUpdater {
url = "${src.meta.homepage}.git";
};
};

meta = with lib; {
isIbusEngine = true;
description = "IBus plugin to allow any Linux application to make use of speech recognition";
homepage = "https://github.com/Elleo/ibus-deepspeech";
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 @@ -4778,6 +4778,8 @@ with pkgs;

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

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

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

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

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

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

qt-mobility = callPackage ../development/libraries/qt-mobility {};
Expand Down Expand Up @@ -32210,6 +32214,8 @@ with pkgs;

stt = callPackage ../tools/audio/stt { };

stt-models = recurseIntoAttrs (callPackages ../tools/audio/stt/models.nix { });

stuntrally = callPackage ../games/stuntrally {
ogre = ogre1_9;
mygui = mygui.override {
Expand Down