示例#1
0
 private static function _ttsApiCaptionify($sentence, $lastEnd, $durationError)
 {
     $speechMp3 = self::_ttsApi($sentence);
     if ($speechMp3) {
         $mp3File = new \Mp3File($speechMp3);
         $metaData = $mp3File->get_metadata();
         unset($mp3File);
         $duration = $metaData['Length'] + $durationError;
         unlink($speechMp3);
         return array('text' => $sentence, 'duration' => $duration, 'start' => $lastEnd, 'end' => $lastEnd + $duration);
     } else {
         return false;
     }
 }
示例#2
0
 public static function samplelookup(&$mp3)
 {
     //bits               MPEG1   MPEG2   MPEG2.5
     $array = array();
     $array['00'] = array('44100', '22050', '11025');
     $array['01'] = array('48000', '24000', '12000');
     $array['10'] = array('32000', '16000', '8000');
     $array['11'] = array('res', 'res', 'res');
     $whichcolumn = -1;
     if (Mp3File::is_mpeg10($mp3)) {
         $whichcolumn = 0;
     } else {
         if (Mp3File::is_mpeg20($mp3)) {
             $whichcolumn = 1;
         } else {
             if (Mp3File::is_mpeg25($mp3)) {
                 $whichcolumn = 2;
             }
         }
     }
     if (isset($array[$mp3['Sampling Freq Idx']][$whichcolumn])) {
         return $array[$mp3['Sampling Freq Idx']][$whichcolumn];
     } else {
         return 'unknown';
     }
 }