-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo.php
More file actions
47 lines (33 loc) · 1.16 KB
/
go.php
File metadata and controls
47 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
date_default_timezone_set("Europe/London");
include_once (__DIR__ .'/config.php');
if(!file_exists(__DIR__ . "/output/")) {
mkdir(__DIR__ . "/output/");
}
$output = __DIR__ . "/output/" . date('ymd');
if (isset($wordnikKey)) {
require(__DIR__ .'/lib/wordnik/api/APIClient.php');
$client = new APIClient($wordnikKey, 'http://api.wordnik.com/v4');
$wordsAPI = new WordsAPI($client);
$word = $wordsAPI->getRandomWord(null);
$output .= "-" . $word->word;
}
mkdir($output);
exec("find \"{$sourceDirectory}\" -name *.wav -print | grep -v output",$out);
echo "found " . count($out). " audio files.\n";
for ($i=0; $i < $numberToGenerate; $i++) {
$file = $out[rand(0,count($out)-1)];
$info = shell_exec("soxi \"{$file}\"");
preg_match("/\d+(?= samples)/", $info, $numberOfSamples);
$length = rand($minLength,$maxLength);
$start = rand (0,$numberOfSamples[0]-$length);
$params = " trim {$start}s {$length}s";
if ($playback==true) {
$cmd = "play --norm \"{$file}\" {$params} repeat 25";
passthru($cmd);
}
$cmd = "sox --norm \"{$file}\" \"{$output}/{$i}.wav\" {$params}";
exec($cmd);
}
echo ("\nCreated {$numberToGenerate} files in ".$output . "\n");
?>