Created
December 2, 2012 11:14
-
-
Save Leask/4188253 to your computer and use it in GitHub Desktop.
A extension of Say command in Mac OS X
This file contains 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
#!/usr/bin/php | |
<?php | |
# Flora Speech by LeaskH.com | |
# Import | |
# Depended on Flora LibCjk ( https://gist.github.com/4153061 ) | |
include_once('/Users/leask/Documents/Working/libcjk/libcjk.php'); | |
# Config | |
$cjk = array('Samantha', 'Sin-Ji'); | |
# Main | |
array_shift($argv); | |
if (!($string = implode(' ', $argv))) { | |
exit(1); | |
} | |
$arrStr = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY); | |
$voices = array(); | |
foreach ($arrStr as $item) { | |
$is_cjk = checkCjk($item); | |
$last = sizeof($voices) - 1; | |
if ($voices && $voices[$last]['is_cjk'] === $is_cjk) { | |
$voices[$last]['content'] .= " {$item}"; | |
} else { | |
$voices[] = array('content' => $item, 'is_cjk' => $is_cjk); | |
} | |
} | |
foreach ($voices as $item) { | |
`say -v "{$cjk[$item['is_cjk']]}" "{$item['content']}"`; | |
} | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment