예제 #1
0
/**
 * Test the basics accessor to the 
 * objects info
 */
void TestSegment::testBasicAccessor()
{
	Segment* seg = Segment::CreateWithDuration(0, 0, NULL);
	seg->SetSpeakerId("bob");
	seg->SetChannel("A");
	seg->SetSource("test");
	assert(seg->GetSpeakerId() == "bob");
	assert(seg->GetChannel() == "A");
	assert(seg->GetSource() == "test");
	delete(seg);
}
예제 #2
0
파일: speech.cpp 프로젝트: AIDman/Kaldi
/**
 * Return the segments of this speech by the given time
 */
vector<Segment*> Speech::GetSegmentsByTime(const int& start, const int& end, const string& source, const string& channel)
{
	vector<Segment*> res;
    
	for (size_t i=0 ; i < m_segments.size() ; ++i)
	{
		Segment *currentSegment = m_segments[i];
		if (currentSegment->GetSource() == source && currentSegment->GetChannel() == channel)
		{
			int s_mid = ((currentSegment->GetEndTime()+currentSegment->GetStartTime()) / 2);
            
			if (s_mid >= start && s_mid < end)
			{
				res.push_back(currentSegment);
			}
		}
	}
	return res;
}
예제 #3
0
파일: speech.cpp 프로젝트: AIDman/Kaldi
/**
* Return the next Segment starting at the specified time for
* the specified source and channel. If the time is in the middle of
* A segment return the segment itself.
*/
Segment* Speech::NextSegment(const int& time, const string& source, const string& channel)
{
	int last_endTime = 0;	
	
	for (size_t i=0 ; i < m_segments.size() ; ++i)
	{
        Segment *currentSegment = m_segments[i];
		
		if (currentSegment->GetSource() == source && currentSegment->GetChannel() == channel)
		{
			if (currentSegment->GetEndTime() > time && last_endTime <= time)
			{
				return currentSegment;
			}
            
			last_endTime = currentSegment->GetEndTime();
		}
	}
    
	return NULL;
}