summaryrefslogtreecommitdiff
path: root/get.pl
diff options
context:
space:
mode:
Diffstat (limited to 'get.pl')
-rwxr-xr-xget.pl57
1 files changed, 57 insertions, 0 deletions
diff --git a/get.pl b/get.pl
new file mode 100755
index 0000000..0ef39db
--- /dev/null
+++ b/get.pl
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+$SIG{TERM} = $SIG{INT} = sub { exit 1 };
+
+chdir('datasets');
+
+my $fn, $new_fn;
+foreach my $s (@ARGV){
+ if ($s =~ /^http/) {
+ if ($s =~ /(wav|aiff?|flac|mp3|opus)$/i) {
+ my $fn = `basename $s`;
+ print "downloading $fn\n";
+ system('/usr/bin/wget', $s);
+ system('/usr/bin/perl', 'dataset.pl', $fn);
+ } else {
+ print "youtube-dl $s\n";
+ my $yt = `youtube-dl --extract-audio --audio-format flac -o "%(title)s.%(ext)s" $s`;
+ my @partz = split("\n", $yt);
+ foreach $part (@partz) {
+ if ($part =~ /\[ffmpeg\] Destination\: (.*\.flac)$/) {
+ $fn = $1;
+ }
+ }
+ if ($fn) {
+ $new_fn = lc $fn;
+ $new_fn =~ s/\.flac$//g;
+ $new_fn =~ s/\s+/_/g;
+ $new_fn =~ s/\W//g;
+ if (length($new_fn) == 0) {
+ $new_fn = lc $s;
+ $new_fn =~ s/\s+/_/g;
+ $new_fn =~ s/\W//g;
+ }
+ $new_fn =~ s/_+/_/g;
+ $new_fn .= '.flac';
+ system('mv', $fn, $new_fn);
+ print"got fn, $fn => $new_fn\n";
+ system('/usr/bin/perl', 'dataset.pl', $new_fn);
+ }
+ }
+ } else {
+ if ($s !~/\..*$/) { $s .= ".wav"; }
+ print "downloading $s\n";
+ system('/usr/bin/wget', 'https://neural:spawn5@asdf.us/neural/' . $s);
+ system('/usr/bin/perl', 'dataset.pl', $s);
+ }
+ open(my $fd, ">>../run_slap.sh");
+ print $fd "standard $fn";
+ close $fn;
+
+ $fn = undef;
+}
+
+END {
+ chdir('..');
+}
+