Compare commits
No commits in common. "5d730f807102c9454fffb25ba03067a45c46ed70" and "4c2b988996d382945bd2bbcd196ebdfd45c37d13" have entirely different histories.
5d730f8071
...
4c2b988996
@ -1,60 +1,65 @@
|
|||||||
{ lib, config, pkgs, ... }: {
|
{ lib, config, pkgs, ... }: {
|
||||||
|
|
||||||
config = lib.mkIf (config.homecfg.make.gui) {
|
config = lib.mkIf (config.homecfg.make.gui) {
|
||||||
home.packages = with pkgs; [
|
# home.packages = with pkgs; [
|
||||||
custom.vosk.base
|
# custom.vosk
|
||||||
jq
|
# custom.vosk.cli
|
||||||
(python3.withPackages (ps: with ps; [ translatepy ]))
|
# custom.vosk.lang.en
|
||||||
];
|
# custom.vosk.lang.ja
|
||||||
|
# custom.vosk.lang.de
|
||||||
|
# custom.vosk.lang.ru
|
||||||
|
# jq
|
||||||
|
# (python3.withPackages (ps: with ps; [ translatepy ]))
|
||||||
|
# ];
|
||||||
|
|
||||||
xdg.configFile."script/transcript-translate.py".text = ''
|
# xdg.configFile."script/transcript-translate.py".text = ''
|
||||||
#!/bin/python
|
# #!/bin/python
|
||||||
|
|
||||||
import sys;
|
# import sys;
|
||||||
from translatepy.translators.google import GoogleTranslate;
|
# from translatepy.translators.google import GoogleTranslate;
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
# if len(sys.argv) != 2:
|
||||||
print("No language provided.")
|
# print("No language provided.")
|
||||||
exit
|
# exit
|
||||||
translator = GoogleTranslate()
|
# translator = GoogleTranslate()
|
||||||
while True:
|
# while True:
|
||||||
for line in sys.stdin:
|
# for line in sys.stdin:
|
||||||
sys.stdout.write(translator.translate(line,sys.argv[1]).result+"\n")
|
# sys.stdout.write(translator.translate(line,sys.argv[1]).result+"\n")
|
||||||
'';
|
# '';
|
||||||
|
|
||||||
xdg.configFile."script/transcript.sh".text = ''
|
# xdg.configFile."script/transcript.sh".text = ''
|
||||||
#!/bin/sh
|
# #!/bin/sh
|
||||||
|
|
||||||
MODELS=(
|
# MODELS=(
|
||||||
"English:${pkgs.custom.vosk.lang.en-us}/usr/share/vosk-models/en-us"
|
# "English:${pkgs.custom.vosklang.en-us}/usr/share/vosk-models/en-us"
|
||||||
"German:${pkgs.custom.vosk.lang.de}/usr/share/vosk-models/de"
|
# "German:${pkgs.custom.vosklang.de}/usr/share/vosk-models/de"
|
||||||
"Russian:${pkgs.custom.vosk.lang.ru}/usr/share/vosk-models/ru"
|
# "Russian:${pkgs.custom.vosklang.ru}/usr/share/vosk-models/ru"
|
||||||
"Japanese:${pkgs.custom.vosk.lang.ja}/usr/share/vosk-models/ja"
|
# "Japanese:${pkgs.custom.vosklang.ja}/usr/share/vosk-models/ja"
|
||||||
)
|
# )
|
||||||
|
|
||||||
MODEL_OPTS=""
|
# MODEL_OPTS=""
|
||||||
for pair in "''${MODELS[@]}"; do
|
# for pair in "''${MODELS[@]}"; do
|
||||||
MODEL_OPTS+="$pair\n"
|
# MODEL_OPTS+="$pair\n"
|
||||||
done
|
# done
|
||||||
|
|
||||||
MODEL_OPT=$(echo -e "$MODEL_OPTS" | wofi --dmenu -p "Choose model:")
|
# MODEL_OPT=$(echo -e "$MODEL_OPTS" | wofi --dmenu -p "Choose model:")
|
||||||
MODEL=$(echo "$MODEL_OPT" | awk -F ':' '{print $2}')
|
# MODEL=$(echo "$MODEL_OPT" | awk -F ':' '{print $2}')
|
||||||
|
|
||||||
TRANSS="None\nNone-prog\nEnglish\nGerman\nRussian\nJapanese"
|
# TRANSS="None\nNone-prog\nEnglish\nGerman\nRussian\nJapanese"
|
||||||
TRANS=$(echo -e "$TRANSS" | wofi --dmenu -p "Choose translation:")
|
# TRANS=$(echo -e "$TRANSS" | wofi --dmenu -p "Choose translation:")
|
||||||
|
|
||||||
export VOSK_MODEL=$MODEL
|
# export VOSK_MODEL=$MODEL
|
||||||
case $TRANS in
|
# case $TRANS in
|
||||||
"None")
|
# "None")
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' 2>/dev/null
|
# voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' 2>/dev/null
|
||||||
;;
|
# ;;
|
||||||
"None-prog")
|
# "None-prog")
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty, .partial // empty | select(length > 0)' 2>/dev/null
|
# voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty, .partial // empty | select(length > 0)' 2>/dev/null
|
||||||
;;
|
# ;;
|
||||||
*)
|
# *)
|
||||||
${pkgs.custom.vosk.cli}/bin/voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' | python ~/.config/script/transcript-translate.py $TRANS
|
# voskcli 2>/dev/null | jq --unbuffered -r '.alternatives[0].text // empty | select(length > 0)' | python ~/.config/script/transcript-translate.py $TRANS
|
||||||
;;
|
# ;;
|
||||||
esac
|
# esac
|
||||||
'';
|
# '';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
xdg.portal = {
|
xdg.portal = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# wlr.enable = true;
|
# wlr.enable = true;
|
||||||
extraPortals = with pkgs; [
|
extraPortals = with pkgs;
|
||||||
|
[
|
||||||
xdg-desktop-portal-hyprland
|
xdg-desktop-portal-hyprland
|
||||||
xdg-desktop-portal-gtk
|
# xdg-desktop-portal-gtk
|
||||||
];
|
];
|
||||||
config.common.default = [ "hyprland" "gtk" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.sessionVariables = rec {
|
environment.sessionVariables = rec {
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
{ lib, pkgs, stdenv, fetchurl, unzip }:
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
name = "vosk-api";
|
|
||||||
version = "0.3.45";
|
|
||||||
src = fetchurl {
|
|
||||||
url =
|
|
||||||
"https://github.com/alphacep/vosk-api/releases/download/v${version}/vosk-linux-x86_64-${version}.zip";
|
|
||||||
sha256 = "sha256-u9yO2FxDl59kQxQoiXcOqVy/vFbP+1xdzXOvqHXF+7I=";
|
|
||||||
};
|
|
||||||
nativeBuildInputs = [ unzip ];
|
|
||||||
unpackCmd = "unzip $curSrc";
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/lib
|
|
||||||
mv libvosk.so $out/lib/
|
|
||||||
mkdir -p $out/include
|
|
||||||
mv vosk_api.h $out/include/
|
|
||||||
'';
|
|
||||||
}
|
|
@ -11,8 +11,8 @@ buildGoModule rec {
|
|||||||
sha256 = "sha256-TeCUtHuBGVyV+YmY3MGaf1jydTWgZITUgmUZzy4wZLU=";
|
sha256 = "sha256-TeCUtHuBGVyV+YmY3MGaf1jydTWgZITUgmUZzy4wZLU=";
|
||||||
};
|
};
|
||||||
preBuild = ''
|
preBuild = ''
|
||||||
export CGO_CFLAGS="-I${pkgs.custom.vosk.base}/include"
|
export CGO_CFLAGS="-I${pkgs.vosk}/include"
|
||||||
export CGO_LDFLAGS="-L${pkgs.custom.vosk.base}/lib"
|
export CGO_LDFLAGS="-L${pkgs.vosk}/lib"
|
||||||
'';
|
'';
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
@ -1,6 +1,26 @@
|
|||||||
{ pkgs, ... }: rec {
|
{ lib, pkgs, stdenv, fetchurl, unzip }:
|
||||||
default = (pkgs.callPackage ./base { });
|
let
|
||||||
base = default;
|
version = "0.3.45";
|
||||||
|
base = stdenv.mkDerivation {
|
||||||
|
name = "vosk-api";
|
||||||
|
version = "${version}";
|
||||||
|
src = fetchurl {
|
||||||
|
url =
|
||||||
|
"https://github.com/alphacep/vosk-api/releases/download/v${version}/vosk-linux-x86_64-${version}.zip";
|
||||||
|
sha256 = "sha256-u9yO2FxDl59kQxQoiXcOqVy/vFbP+1xdzXOvqHXF+7I=";
|
||||||
|
};
|
||||||
|
nativeBuildInputs = [ unzip ];
|
||||||
|
unpackCmd = "unzip $curSrc";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
mv libvosk.so $out/lib/
|
||||||
|
mkdir -p $out/include
|
||||||
|
mv vosk_api.h $out/include/
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
default = (pkgs.callPackage base { });
|
||||||
cli = (pkgs.callPackage ./cli { });
|
cli = (pkgs.callPackage ./cli { });
|
||||||
lang = (pkgs.callPackage ./lang { });
|
lang = (pkgs.callPackage ./lang { });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user