{ pkgs, ... }@all: with all;
{
  home.packages = with pkgs; [
    (writeShellApplication {
      name = "ttss";
      text = let 
        cmd = inp: "piper -m /home/nx2/tts/en_GB-cori-high.onnx --output_raw ${inp} | ffmpeg -hide_banner -loglevel error -f s16le -ar 22050 -ac 1 -i - -f wav - | mpv -"; 
      in /* bash */ ''
        if [ -p /dev/stdin ]; then
          ${cmd "</dev/stdin"} 
        else
          ${cmd ''<<< "$@"''}
        fi
      '';
    })
  ];
}
