id = $id; $this->diarization = $diarization; } // end of member function __construct /** * Get all informations about the file * * @return array * @access private */ private function getInfos() { if ($this->status == "diarization_phase7") { if (!count($this->speakers)) { $speakers = $this->diarization->sendCommand($this->id, 'speakers'); foreach ($speakers as $speaker) { $this->speakers[$speaker->id] = new voxilabSpeaker($speaker->id, $speaker->gender); } } if (!count($this->segments) && count($this->speakers)) { $segments = $this->diarization->sendCommand($this->id, 'segments'); foreach ($segments as $segment) { $voxilabSegment = new voxilabSegment($segment->start, $segment->duration, $this->speakers[$segment->speaker->id]); $this->segments[] = $voxilabSegment; $this->speakers[$segment->speaker->id]->addSegment($voxilabSegment); } } } } /** * Get an array of speakers * * @return array * @access public */ public function getSpeakers( ) { if (!count($this->speakers)) { $this->getInfos(); } return $this->speakers; } // end of member function getSpeakers /** * Get an array of segments * * @return array * @access public */ public function getSegments( ) { if (!count($this->segments)) { $this->getInfos(); } return $this->segments; } // end of member function getSegments /** * Get file status * * @return string * @access public */ public function getStatus( ) { if ($this->status != "diarization_phase7") { $result = $this->diarization->sendCommand($this->id, 'status'); $this->status = $result->status; } return $this->status; } // end of member function getStatus /** * Get a speaker with an id * * @param int id Speaker identifier * @return voxilabSpeaker * @access public */ public function getSpeakerByID( $id ) { if (!count($this->speakers)) { $this->getInfos(); } if ($this->speakers[$id]) { return $this->speakers[$id]; } else return false; } // end of member function getSpeaker /** * Get a segment with a time * * @param float time Time (hundredth of a second) * @return voxilabSegment * @access public */ public function getSegmentByTime( $time ) { if (!count($this->segments)) { $this->getInfos(); } foreach ($this->segments as $segment) { if (($segment->getStart() <= $time) && ($time < $segment->getEnd())) { return $segment; } else continue; } return false; } // end of member function getSegmentByTime /** * Get segments in an interval * * @param float begin Beginning of the interval * @param float end End of the interval * @return voxilabSegment * @access public */ public function getSegmentsInInterval( $begin, $end ) { if (!count($this->segments)) { $this->getInfos(); } $return = array(); foreach ($this->segments as $segment) { if (($segment->getEnd() > $begin) && ($segment->getStart() <= $end)) { $return[] = $segment; } } return $return; } // end of member function getSegmentsInInterval /** * Get segments with a speaker identifier * * @param int speaker Speaker identifier * * @return voxilabSegment */ public function getSegmentsBySpeaker($speaker) { if (!count($this->speakers)) { $this->getInfos(); } return $this->speakers[$speaker]->getSegments(); } public function getID() { return $this->id; } } // end of voxilabSpeechfile ?>