skip to main |
skip to sidebar
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTML::Form;
use Getopt::Std;
print "Text-to-Speech Nabber by sToRm \n";
my $ua = LWP::UserAgent->new();
my %opts;
getopts('EVe:i:o:p:r:v:', \%opts);
if ( defined $opts{'E'} ) {
print "Available effects:\n";
my $response = $ua->get('http://cepstral.com/demos/');
die 'Error: ' . $response->status_line() . "\n" unless $response->is_success();
for ( split(/\n/, $response->content()) ) {
print " $1.sfx\n" if ( $_ =~ // );
}
exit(0);
}
if ( defined $opts{'V'} ) {
print "Available voices:\n";
my $response = $ua->get('http://cepstral.com/demos/');
die 'Error: ' . $response->status_line() . "\n" unless $response->is_success();
for ( split(/\n/, $response->content()) ) {
print " $1\n" if ( $_ =~ /if \(voice=='(.+)'\) {/ );
}
exit(0);
}
if ( defined $opts{'i'} and defined $opts{'o'} ) {
print "Sending initial request.\n";
my $response = $ua->get('http://demos.cepstral.com/cepstral/demos/demo.cgi/cepstral.wav');
die 'Error: ' . $response->status_line() . "\n" unless $response->is_success();
my $form = HTML::Form->parse($response);
print "Success - Applying settings.\n";
$form->value('content', $opts{'i'});
defined $opts{'e'} ? $form->value('effect', $opts{'e'})
: 0;
defined $opts{'p'} ? $form->value('pitch', $opts{'p'})
: 0;
defined $opts{'r'} ? $form->value('rate', $opts{'r'})
: 0;
defined $opts{'v'} ? $form->value('voice', $opts{'v'})
: 0;
print "Fetching audio file.\n";
$ua->request($form->click(), $opts{'o'});
exit(0);
}
print "Usage: perl $0 -i \"Your phrase here\" -o outfile.wav [-EVeprv]\n";
print " -E List available effects\n";
print " -V List available voices\n";
print " -e Select a voice effect (default: None)\n";
print " -i Define the input string\n";
print " -o Define the outfile\n";
print " -p Change the pitch of speech (1-76, default: 1)\n";
print " -r Change the rate of speech (1-3400, default: 170)\n";
print " -v Select a voice to use (default: David)\n";
0 comments:
Post a Comment