def _convertProsody(self, command, attr, default, base): if command.multiplier == 1 and base == default: # Returning to synth default. return speechXml.DelAttrCommand("prosody", attr) else: # Multiplication isn't supported, only addition/subtraction. # The final value must therefore be relative to the synthesizer's default. val = base * command.multiplier - default return speechXml.SetAttrCommand("prosody", attr, "%d%%" % val)
def test_delSingleAttrOfMultipleAttrs(self): """Tests DelAttrCommand removing a single attribute from a tag which has multiple attributes. """ xml = self.balancer.generateXml([ speechXml.SetAttrCommand("prosody", "pitch", 50), speechXml.SetAttrCommand("prosody", "volume", 60), "t1", speechXml.DelAttrCommand("prosody", "pitch"), "t2" ]) self.assertEqual( xml, '<prosody pitch="50" volume="60">t1</prosody><prosody volume="60">t2</prosody>' )
def test_delAttrUnbalanced(self): """Tests DelAttrCommand removing an outer tag before an inner tag. """ xml = self.balancer.generateXml([ speechXml.SetAttrCommand("pitch", "val", 50), speechXml.SetAttrCommand("volume", "val", 60), "t1", speechXml.DelAttrCommand("pitch", "val"), "t2" ]) self.assertEqual( xml, '<pitch val="50"><volume val="60">t1</volume></pitch><volume val="60">t2</volume>' )
def test_setAttrThenDelAttr(self): xml = self.balancer.generateXml([ speechXml.SetAttrCommand("pitch", "val", 50), "t1", speechXml.DelAttrCommand("pitch", "val"), "t2" ]) self.assertEqual(xml, '<pitch val="50">t1</pitch>t2')
def test_delAttrNoSetAttr(self): xml = self.balancer.generateXml( [speechXml.DelAttrCommand("pitch", "val"), "text"]) self.assertEqual(xml, 'text')