My old shell scripts that have been retired from my dotfiles.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
650 B

#!/usr/bin/perl
# gsay - Text to Speech using Google
# Usage: gsay <message>
#
# --Kirsle
# http://sh.kirsle.net/
use strict;
use warnings;
use URI::Escape;
if (scalar(@ARGV) == 0 || $ARGV[0] =~ /^-/) {
die "Usage: $0 <message>\n";
}
my $message = uri_escape(join(" ", @ARGV));
# Check for mplayer.
chomp(my $mplayer = `which mplayer 2>/dev/null`);
if ($? || !$mplayer) {
die "Couldn't find `mplayer` - please install it!\n";
}
# Fork a background process to speak and exit immediately.
exit if fork();
exec("$mplayer -ao alsa -really-quiet -noconsolecontrols \"http://translate.google.com/translate_tts?tl=en&q=$message\" >/dev/null 2>&1");