Created
January 31, 2018 16:22
-
-
Save stormsweeper/92aa77bf1e40e9822bf0466fd54f1346 to your computer and use it in GitHub Desktop.
Plays random words in random voices at random speeds. Specify the time in seconds you want to play, e.g. `php glossolalia.php 30`. Default is 10 seconds.
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'))); | |
$stop = time() + (intval($argv[1]) ?: 10); | |
while (time() < $stop) { | |
$voice = $voices[array_rand($voices)]; | |
$word = $words[array_rand($words)]; | |
$wpm = rand(50, 500); | |
exec("say -v {$voice} -r {$wpm} {$word}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment