def mockEnvConversion(env): if env == 'b': b = [ ContentElement(), ProsodyElement(duration='3000ms'), ArgElement(2), ProsodyElement(duration='5000ms') ] b[1].insertChild(0, ContentElement()) b[1].insertChild(0, ArgElement(1)) b[3].insertChild(0, ProsodyElement(duration='9000s')) return b else: return None
def mockEnvConversion(env): if env == 'b': b = [ ContentElement(), ProsodyElement(pitch='-40%'), ArgElement(2), ProsodyElement(pitch='none') ] b[1].insertChild(0, ContentElement()) b[1].insertChild(0, ArgElement(1)) b[3].insertChild(0, ProsodyElement(pitch='90%')) return b else: return None
def mockEnvConversion(env): if env == 'b': b = [ ContentElement(), ProsodyElement(volume='-3dB'), ArgElement(2), ProsodyElement(volume='none') ] b[1].insertChild(0, ContentElement()) b[1].insertChild(0, ArgElement(1)) b[3].insertChild(0, ProsodyElement(volume='loud')) return b else: return None
def mockEnvConversion(env): if env == 'b': b = [ ContentElement(), EmphasisElement(level='moderate'), ArgElement(2), EmphasisElement(level='none') ] b[1].insertChild(0, ContentElement()) b[1].insertChild(0, ArgElement(1)) b[3].insertChild(0, EmphasisElement(level='strong')) return b else: return None
def mockEnvConversion(env): if env == 'b': return [ BreakElement(strength='strong'), ContentElement(), BreakElement(strength='weak') ] else: return None
def mockEnvConversion(env): if env == 'a': a = [TextElement('text2')] return a if env == 'b': b = [ContentElement()] return b else: return None
def mockEnvConversion(env): if env == 'b': b = [ ArgElement(1, 'bracket'), ArgElement(4, argType='brace'), ContentElement() ] return b else: return None
def _getSSMLElement(self, xml_node): element = None if xml_node.tag == 'break': args = {} if 'time' in xml_node.attrib: args['time'] = xml_node.attrib['time'] if 'strength' in xml_node.attrib: args['strength'] = xml_node.attrib['strength'] element = BreakElement(**args) elif xml_node.tag == 'emphasis': args = {} if 'level' in xml_node.attrib: args['level'] = xml_node.attrib['level'] element = EmphasisElement(**args) elif xml_node.tag == 'prosody': args = {} if 'volume' in xml_node.attrib: args['volume'] = xml_node.attrib['volume'] if 'rate' in xml_node.attrib: args['rate'] = xml_node.attrib['rate'] if 'pitch' in xml_node.attrib: args['pitch'] = xml_node.attrib['pitch'] if 'duration' in xml_node.attrib: args['duration'] = xml_node.attrib['duration'] element = ProsodyElement(**args) elif xml_node.tag == 'p': element = ParagraphElement() elif xml_node.tag == 'arg': if 'argType' in xml_node.attrib: element = ArgElement(xml_node.attrib['num'], argType=xml_node.attrib['argType']) else: element = ArgElement(xml_node.attrib['num']) elif xml_node.tag == 'content': element = ContentElement() else: raise RuntimeError('Unhandled tag "' + xml_node.tag + '"encountered in conversion database') if element: if xml_node.text and not xml_node.text.isspace(): element.setHeadText(xml_node.text.strip(" \t\n\r")) if xml_node.tail and not xml_node.tail.isspace(): element.setTailText(xml_node.tail.strip(" \t\n\r")) for child in xml_node.findall('./*'): element.insertChild(-1, self._getSSMLElement(child)) return element
def mockEnvConversion(env): if env == 'b': return [TextElement('text 2'), ContentElement()] else: return None