This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / configs / services / radio / tts.nix
1.3 kB 50 lines
1{ pkgs, ... }: 2let 3 model = pkgs.runCommand "model" { } '' 4 mkdir -p $out 5 ln -s ${ 6 pkgs.fetchurl { 7 url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts/high/en_US-libritts-high.onnx?download=true"; 8 hash = "sha256-kSelWeEWA/ELNm0aIKx0JoJggdvFId5MJCDFdyjXPw8="; 9 } 10 } $out/model.onnx 11 ln -s ${ 12 pkgs.fetchurl { 13 url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts/high/en_US-libritts-high.onnx.json?download=true"; 14 hash = "sha256-Lv3G1/lUWIuBgBMsvZuAAZM/3QCTLJK8kv0NICip6z0="; 15 } 16 } $out/model.onnx.json 17 ''; 18 19 tts = pkgs.writers.writeBashBin "tts" '' 20 set -efu 21 set -x 22 23 offset=0 24 OUTPUT=$(mktemp -d) 25 trap 'rm -rf "$OUTPUT"' EXIT 26 SPEAKER=$[ $RANDOM % 900 ] 27 while read line; do 28 # skip empty lines, piper crashes on empty input 29 if [ -z "$line" ]; then 30 continue 31 fi 32 filename=$(printf '%04d' $offset).wav 33 echo "$line" | 34 ${pkgs.piper-tts}/bin/piper \ 35 --model ${model}/model.onnx \ 36 -s "$SPEAKER" \ 37 -f "$OUTPUT"/"$filename" >/dev/null 38 39 ((offset+=1)) 40 done 41 42 ${pkgs.sox}/bin/sox "$OUTPUT"/*.wav "$OUTPUT"/all.wav 43 cat "$OUTPUT"/all.wav 44 ''; 45in 46{ 47 environment.systemPackages = [ 48 tts 49 ]; 50}