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.

28 lines
650 B

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