def test_convertComplex(self):
        """Test converting a complex speech sequence to SSML.
		XML generation is already tested by TestXmlBalancer.
		However, SSML is what callers expect at the end of the day,
		so test converting a complex speech sequence to SSML.
		Depends on behavior tested by TestXmlBalancer.
		"""
        converter = speechXml.SsmlConverter("en_US")
        xml = converter.convertToXml([
            "t1",
            speech.PitchCommand(multiplier=2),
            speech.VolumeCommand(multiplier=2), "t2",
            speech.PitchCommand(),
            speech.LangChangeCommand("de_DE"),
            speech.CharacterModeCommand(True),
            speech.IndexCommand(1), "c",
            speech.CharacterModeCommand(False),
            speech.PhonemeCommand("phIpa", text="phText")
        ])
        self.assertEqual(
            xml,
            '<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">'
            't1'
            '<prosody pitch="200%" volume="200%">t2</prosody>'
            '<prosody volume="200%"><voice xml:lang="de-DE">'
            '<mark name="1"/><say-as interpret-as="characters">c</say-as>'
            '<phoneme alphabet="ipa" ph="phIpa">phText</phoneme>'
            '</voice></prosody></speak>')
Beispiel #2
0
	def generateBalancerCommands(self, speechSequence):
		commands = super(_OcPreAPI5SsmlConverter, self).generateBalancerCommands(speechSequence)
		# The EncloseAllCommand from SSML must be first.
		yield next(commands)
		# OneCore didn't provide a way to set base prosody values before API version 5.
		# Therefore, the base values need to be set using SSML.
		yield self.convertRateCommand(speech.RateCommand(multiplier=1))
		yield self.convertVolumeCommand(speech.VolumeCommand(multiplier=1))
		yield self.convertPitchCommand(speech.PitchCommand(multiplier=1))
		for command in commands:
			yield command