Replies: 8 comments 20 replies
-
Is it possible to prevent piper from terminating and restarting after every sentence, it takes a lot of time after each sentence? I saw this in the log of speech-dispatcher. |
Beta Was this translation helpful? Give feedback.
-
Hey @takov751 this works pretty well for being "hacked together". I've just encountered two issues so far. The first is that the audio stops if I write a long sentence using spd-say, so it doesn't finish saying it. And the other is that apps that connect to speech-dispatcher like firefox and foliate give me an error saying they can't use speech-dispatcher. Does anyone know how these issues can be resolved? |
Beta Was this translation helpful? Give feedback.
-
Could you please give some description to non-technical users like me:
what these values are and how can I replace them to chose different voice? How to find this classification for equivalent of "MALE1", for example I typed For example in Plasma Okular there is an option to change voice (this also sometimes means language). But with proposed configuration I don't know how to make other voices available for speech dispatcher. |
Beta Was this translation helpful? Give feedback.
-
I want to use another voice(german) instead the default one(english): not sure why I still hear the default english voice. My code should work and use the german voice I've installed. If I change the default voice under pied's settings to german, all english articles sound wrong, of course. (OS:Mint). |
Beta Was this translation helpful? Give feedback.
-
Hi, I followed this guide (I think) but it doesn't work. When I try this command (just for testing), it works.
But the integration with speechd doesn't. Here is my config
In the logs I can see
It seems that piper cannot find the model's config even though it is at the right place. |
Beta Was this translation helpful? Give feedback.
-
On arch installing
and rebooting was enough for it to work. It creates a
which for some reason isn't explicitly loaded into the |
Beta Was this translation helpful? Give feedback.
-
I think I finally made it work in nixOS @Cameo007 {
config,
lib,
pkgs,
...
}:
let
cfg = config.mySystem.piperTextToSpeech;
user = "yeshey";
rmNewLines = pkgs.writeShellScriptBin "rmNewLines"
''
echo "''${1//$'\n'/ }"
'';
piperVoices = {
en_US_amy = {
onnx = builtins.fetchurl {
url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/amy/medium/en_US-amy-medium.onnx?download=true";
sha256 = "sha256:063c43bbs0nb09f86l4avnf9mxah38b1h9ffl3kgpixqaxxy99mk"; # Replace with the actual sha256 hash after running `nix-build`.
};
json = builtins.fetchurl {
url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/amy/medium/en_US-amy-medium.onnx.json";
sha256 = "sha256:0xvxjxk59byydx9gj6rdvvydp5zm8mzsrf9vyy6x6299sjs3x8lm"; # Replace with the actual sha256 hash after running `nix-build`.
};
};
en_US_libritts_r = {
onnx = builtins.fetchurl {
url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx?download=true";
sha256 = "sha256:159iq7x4idczq4p5ap9wmf918jfhk4brydhz0zsgq5nnf7h8bfqh"; # Replace with the actual sha256 hash after running `nix-build`.
};
json = builtins.fetchurl {
url = "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx.json";
sha256 = "sha256:1cxgr5dm0y4q4rxjal80yhbjhydzdxnijg9rkj0mwcyqs9hdqwdl"; # Replace with the actual sha256 hash after running `nix-build`.
};
};
};
createFile = { name, content }: ''
mkdir -p "$(dirname /home/${user}/.config/${name})"
echo '${content}' > /home/${user}/.config/${name}
'';
in
{
options.mySystem.piperTextToSpeech = {
enable = lib.mkEnableOption "Enable Piper Text-to-Speech.";
};
config = lib.mkIf (config.mySystem.enable && cfg.enable) {
# Use userActivationScripts to configure Piper and Speech Dispatcher
system.userActivationScripts.piperSpeechDispatcher = ''
# Create Piper configuration in user-specific locations
${createFile {
name = "speech-dispatcher/modules/piper.conf";
content = ''
GenericExecuteSynth '\''''''echo "$(${rmNewLines}/bin/rmNewLines "$DATA")" | ${pkgs.piper-tts}/bin/piper --model /etc/piper-voices/en_US-libritts_r-medium.onnx --output_raw --sentence_silence 0.1 | ${pkgs.sox}/bin/play -t raw -r 22050 -e signed-integer -b 16 -c 1 - tempo $(echo "1 + ($RATE / 100) * (2.5 - 1)" | ${pkgs.bc}/bin/bc -l) '\''''''
AddVoice "en-US" "male1" "en/en_US/libritts_r/medium/en_US-libritts_r-medium.onnx"
'';
}}
${createFile {
name = "speech-dispatcher/speechd.conf";
content = ''
AddModule "piper" "sd_generic" "piper.conf"
DefaultVoiceType "male1"
DefaultLanguage en-US
DefaultModule piper
'';
}}
'';
#environment.etc."piper-voices/en_US-amy-medium.onnx".source = piperVoices.en_US_amy.onnx;
#environment.etc."piper-voices/en_US-amy-medium.onnx.json".source = piperVoices.en_US_amy.json;
environment.etc."piper-voices/en_US-libritts_r-medium.onnx".source = piperVoices.en_US_libritts_r.onnx;
environment.etc."piper-voices/en_US-libritts_r-medium.onnx.json".source = piperVoices.en_US_libritts_r.json;
# Ensure Piper and Speech Dispatcher are installed
environment.systemPackages = with pkgs; [
speechd
piper-tts
pipewire
sox
bc
];
};
} Edit: Removing new lines so it doesnt mess up reading pdfs |
Beta Was this translation helpful? Give feedback.
-
I have found one major issue in using
Does anyone have a solution for this? perhaps a process that runs in the background that loads the model and then simply waits for input? |
Beta Was this translation helpful? Give feedback.
-
I was able to hack it together, it was rather simple.
Install speech-dispatcher then in
/etc/speech-dispatcher/modules/piper.conf
/etc/speech-dispatcher/speechd.conf
and you have piper as narrator on your desktop. Of course there is lot of room for improvement, but slowly getting there
/path/to/voice/
should be the directory you have downloaded the voices from huggingfaceBeta Was this translation helpful? Give feedback.
All reactions