예제 #1
0
    def test_phonetized_sample(self):
        tg = TextGrid()
        tg.read(os.path.join(SAMPLES,"DGtdA05Np1_95-phon.TextGrid"))
        self.tier = tg.Find('Phonetization')
        tiermap = TierMapping( os.path.join(SAMPLES,"ita_mapping.repl") )

        tiermap.set_keepmiss( True )
        tiermap.set_reverse( False )
        t = tiermap.run( self.tier )
        tiermap.set_reverse( True )
        tp = tiermap.run( t )
        for a1, a2 in zip(tp, self.tier):
            self.assertEqual(a1.GetLabel().GetValue(), a2.GetLabel().GetValue())
            self.assertEqual(a1.GetLocation().GetValue(), a2.GetLocation().GetValue())
예제 #2
0
    def test_aligned_sample(self):
        tg = TextGrid()
        tg.read(os.path.join(SAMPLES,"DGtdA05Np1_95-palign.TextGrid"))
        self.tier = tg.Find('PhonAlign')
        tiermap = TierMapping( os.path.join(SAMPLES,"ita_mapping.repl") )

        tiermap.set_keepmiss( True )
        t1 = tiermap.run( self.tier )
        tiermap.set_keepmiss( False )
        t2 = tiermap.run( self.tier )
        for a1, a2 in zip(t1, t2):
            if a1.GetLabel().IsSilence() is True:
                self.assertNotEqual(a1.GetLabel().GetValue(), a2.GetLabel().GetValue())
                self.assertNotEqual(a1.GetLocation().GetValue(), a2.GetLocation().GetValue())
            else:
                self.assertEqual(a1.GetLabel().GetValue(), a2.GetLabel().GetValue())
                self.assertEqual(a1.GetLocation().GetValue(), a2.GetLocation().GetValue())
예제 #3
0
 def test_ReadPointsLong(self):
     tg1 = TextGrid()
     tg2 = TextGrid()
     tg1.read(os.path.join(SAMPLES, "sample_points.TextGrid"))
     tg1.write(os.path.join(SAMPLES, "sample_points2.TextGrid"))
     tg2.read(os.path.join(SAMPLES, "sample_points2.TextGrid"))
     for t1, t2 in zip(tg1, tg2):
         self.assertEqual(t1.GetSize(), t2.GetSize())
         for a1, a2 in zip(t1, t2):
             self.assertEqual(a1.GetLabel().GetValue(),
                              a2.GetLabel().GetValue())
             self.assertEqual(a1.GetLocation().GetValue(),
                              a2.GetLocation().GetValue())