def mockCmdConversion(cmd): if cmd == 'a': a = [ProsodyElement(duration='2000s'), ArgElement(1)] a[0].insertChild(0, ProsodyElement(duration='1000s')) a[0].children[0].insertChild(0, ArgElement(2)) return a else: return None
def mockCmdConversion(cmd): if cmd == 'a': a = [ProsodyElement(pitch='x-low'), ArgElement(1)] a[0].insertChild(0, ProsodyElement(pitch='high')) a[0].children[0].insertChild(0, ArgElement(2)) return a else: return None
def mockCmdConversion(cmd): if cmd == 'a': a = [ProsodyElement(volume='x-loud'), ArgElement(1)] a[0].insertChild(0, ProsodyElement(volume='medium')) a[0].children[0].insertChild(0, ArgElement(2)) return a else: return None
def mockCmdConversion(cmd): if cmd == 'a': a = [EmphasisElement(level='strong'), ArgElement(1)] a[0].insertChild(0, EmphasisElement(level='reduced')) a[0].children[0].insertChild(0, ArgElement(2)) return a else: return None
def mockCmdConversion(cmd): if cmd == 'a': a = [ArgElement(2), ArgElement('1', argType='bracket')] return a elif cmd == 'd': d = [BreakElement()] return d else: return None
def mockEnvConversion(env): if env == 'b': b = [ ArgElement(1, 'bracket'), ArgElement(4, argType='brace'), ContentElement() ] return b else: return None
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 _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 mockEnvDefinition(env): if env == 'b': return {'a': [ArgElement(1), ArgElement('2', argType='bracket')], \ 'c': [ArgElement(3)], 'mathmode': False} else: return None