[Fix] Allow selecting of voice packs.

This commit is contained in:
Ritchie Cunningham 2025-06-07 17:16:45 +01:00
parent 44c8e829db
commit 3c48e91174

View File

@ -23,7 +23,7 @@ sub notify {
my ($title, $message) = @_; my ($title, $message) = @_;
system("notify-send", "-i", "irssi", $title, $message); system("notify-send", "-i", "irssi", $title, $message);
if (Irssi::settings_get_bool('festival_enabled')) { if(Irssi::settings_get_bool('festival_enabled')) {
my $text_to_speak = "$title, $message"; my $text_to_speak = "$title, $message";
# Fork the process to prevent Irssi from freezing while festival speaks. # Fork the process to prevent Irssi from freezing while festival speaks.
@ -35,14 +35,16 @@ sub notify {
# This will offload the entire backgrounding task to the systemd service # This will offload the entire backgrounding task to the systemd service
# manager. # manager.
# We need to escape any single quotes in the text..
# Sorry @dacav, tried to use your open() suggestion, but as we can't # Sorry @dacav, tried to use your open() suggestion, but as we can't
# daemonise using the fork solution, we have to manually prevent shell injection. # daemonise using the fork solution, we have to manually prevent shell injection.
$text_to_speak =~ s/'/'\\''/g;
my $command = "echo '$text_to_speak' | festival --tts --language english --pipe"; $text_to_speak =~ s/\\/\\\\/g; # Must escape backslashes first
$text_to_speak =~ s/"/\\"/g; # Then escape double-quotes
system("systemd-run", "--user", "--quiet", "--no-ask-password", "/bin/sh", "-c", $command) my $scheme_command = "$festival_voice(SayText \"$text_to_speak\")";
$scheme_command =~ s/'/'\\''/g;
my $command = "echo '$scheme_command' | festival";
system("systemd-run", "--user", "--quiet", "--no-ask-password", "/bin/sh", "-c", $command);
} }
} }
@ -51,7 +53,7 @@ sub notify {
# Private messages are simple and clean. No theme conflicts. # Private messages are simple and clean. No theme conflicts.
sub private_message_handler { sub private_message_handler {
my ($server, $msg, $nick, $address) = @_; my ($server, $msg, $nick, $address) = @_;
return if ($nick =~ /^(NickServ|ChanServ|MemoServ)$/i); return if($nick =~ /^(NickServ|ChanServ|MemoServ)$/i);
notify("Private Message from $nick", $msg); notify("Private Message from $nick", $msg);
} }
@ -68,7 +70,7 @@ sub print_text_handler {
# Check if the level is a highlight and the target matches the one we just saved. # Check if the level is a highlight and the target matches the one we just saved.
# The target check prevents us from misfiring on other window text. # The target check prevents us from misfiring on other window text.
if (($dest->{level} & Irssi::MSGLEVEL_HILIGHT) && ($dest->{target} eq $last_public_target)) { if(($dest->{level} & Irssi::MSGLEVEL_HILIGHT) && ($dest->{target} eq $last_public_target)) {
# Make sure the data from the first signal is actually there. # Make sure the data from the first signal is actually there.
return unless defined $last_public_nick; return unless defined $last_public_nick;