Created
January 31, 2018 18:11
-
-
Save bgreenlee/a7dd8494a83d20dcdfce76a33bad1752 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (strpos(`uname`, 'Darwin') === false) { | |
fwrite(STDERR, "This only works on macOS, sorry.\n"); | |
exit(1); | |
} | |
$voices = array_map( | |
function($voice) { | |
return (explode(' ', $voice))[0]; | |
}, | |
explode("\n", trim(`say -v ?`)) | |
); | |
$words = explode("\n", trim(file_get_contents('/usr/share/dict/words'))); | |
$num_voices = intval($argv[1]) ?: 10; | |
$num_words = intval($argv[2]) ?: 10; | |
for ($i=0; $i < $num_voices ; $i++) { | |
$voice = $voices[array_rand($voices)]; | |
$word_list = join(" ", array_map(function() use ($words) { return $words[array_rand($words)]; }, range(1, $num_words))); | |
$wpm = rand(80, 120); | |
exec("say -v {$voice} -r {$wpm} {$word_list} > /dev/null 2>/dev/null &"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment