{ lib, stdenv, fetchurl, unzip }:
let
  vosk_model_wrapper = { name, version, hash }:
    stdenv.mkDerivation {
      name = name;
      version = version;
      src = fetchurl {
        url =
          "https://alphacephei.com/kaldi/models/vosk-model-${name}-${version}.zip";
        sha256 = hash;
      };
      nativeBuildInputs = [ unzip ];
      unpackCmd = "unzip $curSrc";

      installPhase = ''
        mkdir -p $out/usr/share/vosk-models
        cp -r . $out/usr/share/vosk-models/${name}
      '';
    };
in {
  small-en-us = vosk_model_wrapper {
    name = "small-en-us";
    version = "0.15";
    hash = "sha256-MPJiQsTrRJ+UjkLLMC3XpobLKaNCOoNn+Z/0F4CUJJg=";
  };

  en-us = vosk_model_wrapper {
    name = "en-us";
    version = "0.22";
    hash = "sha256-R/moHrsDnbsL0xkXXDasOTwIk7eWwrYwPmTPWMJ7afY=";
  };

  ru = vosk_model_wrapper {
    name = "ru";
    version = "0.22";
    hash = "sha256-hNniz2MkSA5Odo2n11Ei/RJQ31RJuJ2PnZQX7Hon+yM=";
  };

  small-ja = vosk_model_wrapper {
    name = "small-ja";
    version = "0.22";
    hash = "sha256-76CS0oAVOndhXp4MfXKD6T5gDePRnTvsaGxX7xnVLqw=";
  };

  ja = vosk_model_wrapper {
    name = "ja";
    version = "0.22";
    hash = "sha256-r2INuBXvcW+QNV+REJK6DHRU2R15Ps3Y3uLfY0Lg6cw=";
  };

  small-de = vosk_model_wrapper {
    name = "small-de";
    version = "0.15";
    hash = "sha256-t+U8kLHwo4RW9M1is2bs1YgDzZfNQrBkOOLBMXE9XkM=";
  };

  de = vosk_model_wrapper {
    name = "de";
    version = "0.21";
    hash = "sha256-JFBgdW+Ng5T8WxNjnPIgt2ICBXlfMPN7aCOHjU9gOyo=";
  };
}
