Skip to content

Instantly share code, notes, and snippets.

@Leask
Created December 2, 2012 11:14
Show Gist options
  • Save Leask/4188253 to your computer and use it in GitHub Desktop.
Save Leask/4188253 to your computer and use it in GitHub Desktop.
A extension of Say command in Mac OS X
#!/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