Speak
view release on metacpan or search on metacpan
#!/usr/bin/perl
=pod
=head1 NAME speak
Simply speaks the passed in message, clipboard or file
=head1 VERSION
=over
=item Author
Andrew DeFaria <Andrew@DeFaria.com>
=item Created:
=back
=head1 SYNOPSIS
Usage: speak [-usa|ge] [-h|elp] [-v|erbose] [-de|bug]
[-c|lipboard] [-f|ile <filename>] ["message"]
Where:
-usa|ge: Print this usage
-h|elp: Detailed help
-c|lipboard: Speak the contents of the clipboard
-f|ile <filename> Speak the contents of <filename>
"message" Speak the message
=head1 DESCRIPTION
This script speaks the contents of the passed in message, clipboard or file
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Speak qw(speak);
my %opts = (
usage => sub {pod2usage},
help => sub {pod2usage (-verbose => 2)},
## no critic (Variables::RequireLocalizedPunctuationVars)
verbose => sub {$verbose = 1; $ENV{VERBOSE} = 1},
debug => sub {$debug = 1; $ENV{DEBUG} = 1},
);
## Main
GetOptions (\%opts, 'usage', 'help', 'verbose', 'debug', 'clipboard', 'file=s',)
|| pod2usage;
my $msg = join ' ', @ARGV;
if ($opts{clipboard}) {
if ($opts{file}) {
error 'Cannot specify both -clipboard and -file', 1;
} elsif ($msg) {
error 'Cannot specify both -clipboard and <message>', 1;
} else {
$msg = Clipboard->paste;
} # if
} elsif ($opts{file}) {
if ($msg) {
error 'Cannot specify both -file and <message>', 1;
} else {
open my $file, '<', $opts{file}
or error "Unable to open $opts{file} - $!", 1;
#!/usr/bin/perl
=pod
=head1 NAME speak
Simply speaks the passed in message, clipboard or file
=head1 VERSION
=over
=item Author
Andrew DeFaria <Andrew@DeFaria.com>
=item Created:
=back
=head1 SYNOPSIS
Usage: speak [-usa|ge] [-h|elp] [-v|erbose] [-de|bug]
[-c|lipboard] [-f|ile <filename>] ["message"]
Where:
-usa|ge: Print this usage
-h|elp: Detailed help
-c|lipboard: Speak the contents of the clipboard
-f|ile <filename> Speak the contents of <filename>
"message" Speak the message
=head1 DESCRIPTION
This script speaks the contents of the passed in message, clipboard or file
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Speak qw(speak);
my %opts = (
usage => sub {pod2usage},
help => sub {pod2usage (-verbose => 2)},
## no critic (Variables::RequireLocalizedPunctuationVars)
verbose => sub {$verbose = 1; $ENV{VERBOSE} = 1},
debug => sub {$debug = 1; $ENV{DEBUG} = 1},
);
## Main
GetOptions (\%opts, 'usage', 'help', 'verbose', 'debug', 'clipboard', 'file=s',)
|| pod2usage;
my $msg = join ' ', @ARGV;
if ($opts{clipboard}) {
if ($opts{file}) {
error 'Cannot specify both -clipboard and -file', 1;
} elsif ($msg) {
error 'Cannot specify both -clipboard and <message>', 1;
} else {
$msg = Clipboard->paste;
} # if
} elsif ($opts{file}) {
if ($msg) {
error 'Cannot specify both -file and <message>', 1;
} else {
open my $file, '<', $opts{file}
or error "Unable to open $opts{file} - $!", 1;
lib/Speak.pm view on Meta::CPAN
Parameters:
=for html <blockquote>
=over
=item $msg:
Message to speak. If $msg is defined and scalar then that is the message
to speak. If it is a file handle then the text will be read from that file.
Otherwise the text in the clipboard will be used.
=item $log
If provided, errors and messages will be logged to the logfile, otherwise to speak.log
=item $lang
Language code (e.g. 'en', 'en-gb', 'en-au'). Defaults to $ENV{SPEAK_LANG} or 'en'.
=back
( run in 2.009 seconds using v1.01-cache-2.11-cpan-2398b32b56e )