def test_set_methods(self):
        expected_response = '<Response><Speak><emphasis level="strong"><break strength="strong"/>' \
                            '<lang xml:lang="it">This is Test</lang><emphasis level="strong">' \
                            'This is Test</emphasis><phoneme alphabet="ipa" ph="t&amp;#x259;mei&amp;#x325;' \
                            '&amp;#x27E;ou&amp;#x325;">This is Test</phoneme><prosody pitch="low">' \
                            'This is Test</prosody><say-as format="" interpret-as="spell-out">' \
                            'This is Test</say-as><sub alias="World Wide Web Consortium">This is Test' \
                            '</sub><w role="claws:VV0">This is Test</w></emphasis></Speak></Response>'
        level = "strong"
        content_break = 'This is Test'
        strength_break = 'strong'
        time_break = '250ms'

        content_lang = 'This is Test'
        xmllang_lang = "it"

        content_emphasis = 'This is Test'
        level_emphasis = 'strong'

        content_phoneme = 'This is Test'
        alphabet_phoneme = "ipa"
        ph_phoneme = "t&#x259;mei&#x325;&#x27E;ou&#x325;"

        content_prosody = "This is Test"
        volume_prosody = "+6dB"
        rate_prosody = "x-high"
        pitch_prosody = "low"

        content_say_as = 'This is Test'
        interpret_as_say_as = "spell-out"
        format_say_as = ""

        content_sub = "This is Test"
        alias_sub = "World Wide Web Consortium"

        content_w = "This is Test"
        role_w = "claws:VV0"

        element = plivoxml.ResponseElement()
        response = element.add(
            plivoxml.SpeakElement("").add(
                plivoxml.EmphasisElement().set_level(level).add_break(
                    strength=strength_break).add_lang(
                        content_lang, xmllang=xmllang_lang).add_emphasis(
                            content_emphasis,
                            level=level_emphasis).add_phoneme(
                                content_phoneme,
                                alphabet=alphabet_phoneme,
                                ph=ph_phoneme).add_prosody(
                                    content_prosody,
                                    pitch=pitch_prosody).add_say_as(
                                        content_say_as,
                                        interpret_as=interpret_as_say_as,
                                        format=format_say_as).add_sub(
                                            content_sub,
                                            alias=alias_sub,
                                        ).add_w(content_w,
                                                role_w))).to_string(False)
        self.assertEqual(response, expected_response)
 def test_add_speak(self):
     response = plivoxml.ResponseElement()
     response.add(
         plivoxml.SpeakElement(
             'Please leave a message after the beep. Press the star key when done.'
         ))
     response.add(
         plivoxml.RecordElement(
             action='http://foo.com/get_recording/',
             max_length=30,
             finish_on_key='*'))
     response.add(plivoxml.SpeakElement('Recording not received.'))
     elem = response.to_string()
     self.assertEqual(
         elem,
         '<Response><Speak>Please leave a message after the beep. Press the star key when done.</Speak><Record action="http://foo.com/get_recording/" finishOnKey="*" maxLength="30"></Record><Speak>Recording not received.</Speak></Response>\n'
     )
示例#3
0
    def test_set_methods(self):
        expected_response = '<Response><Speak>substitution example <sub alias="World Wide Web Consortium">W3C</sub></Speak></Response>'
        alias = "World Wide Web Consortium"

        element = plivoxml.ResponseElement()
        response = element.add(
            plivoxml.SpeakElement("substitution example ").add(
                plivoxml.SubElement("W3C").set_alias(alias))).to_string(False)
        self.assertEqual(response, expected_response)
 def test_set_methods(self):
     time = "1000ms"
     strength = "x-strong"
     expected_response = '<Response><Speak voice="Polly.Joey">Break of<break strength="x-strong" time="1000ms"/> one second or same as paragraph </Speak></Response>'
     element = plivoxml.ResponseElement()
     response = element.add(
         plivoxml.SpeakElement("Break of", "Polly.Joey").add(
             plivoxml.BreakElement().set_strength(strength).set_time(time)).
         add_cont("one second or same as paragraph")).to_string(False)
     self.assertEqual(response, expected_response)
    def test_set_methods(self):
        alphabet = "ipa"
        ph = "t&#x259;mei&#x325;&#x27E;ou&#x325;"
        expected_response = '<Response><Speak><phoneme alphabet="ipa" ph="t&amp;#x259;mei&amp;' \
                            '#x325;&amp;#x27E;ou&amp;#x325;">Well</phoneme></Speak></Response>'

        element = plivoxml.ResponseElement()
        response = element.add(
            plivoxml.SpeakElement("").add(
                plivoxml.PhonemeElement("Well").set_alphabet(alphabet).set_ph(
                    ph))).to_string(False)
        self.assertEqual(response, expected_response)
示例#6
0
 def test_complex(self):
     self.assertEqual(
         plivoxml.ResponseElement().add(
             plivoxml.MessageElement('text', '123', '456')).add(
                 plivoxml.ConferenceElement('name')).add(
                     plivoxml.DTMFElement('123')).add(
                         plivoxml.WaitElement()).add(
                             plivoxml.SpeakElement('Hello')).
         add(plivoxml.PreAnswerElement().add_speak('Hello')).add(
             plivoxml.PlayElement('url')).add(
                 plivoxml.DialElement().set_caller_name('Test').add(
                     plivoxml.NumberElement('123').set_send_on_preanswer(
                         True))).to_string(),
         '<Response><Message dst="456" src="123">text</Message><Conference>name</Conference><DTMF>123</DTMF><Wait></Wait><Speak>Hello</Speak><PreAnswer><Speak>Hello</Speak></PreAnswer><Play>url</Play><Dial callerName="Test"><Number sendOnPreanswer="true">123</Number></Dial></Response>\n'
     )
示例#7
0
    def test_set_methods(self):
        expected_response = '<Response><Speak><say-as format="application/ssml+xml" interpret-as="spell-out">' \
                            'This is Test</say-as></Speak></Response>'
        interpret_as = "spell-out"
        format = "application/ssml+xml"
        content = 'This is Test'

        element = plivoxml.ResponseElement()

        response = element.add(
            plivoxml.SpeakElement("").add(
                plivoxml.SayAsElement(content).set_interpret_as(
                    interpret_as).set_format(format))).to_string(False)

        self.assertEqual(response, expected_response)
    def test_set_methods(self):
        expected_response = '<Response><Speak language="en-US" loop="1" voice="Polly.Joey">This is Test' \
                            '<break time="250ms"/><emphasis ' \
                            'level="strong">This is Test</emphasis><lang xml:lang="it">This is Test</lang>' \
                            '<p>This is Test</p><phoneme alphabet="ipa" ph="t&amp;#x259;mei&amp;#x325;' \
                            '&amp;#x27E;ou&amp;#x325;">This is Test</phoneme><prosody pitch="low" ' \
                            'rate="x-high" volume="+6dB">This is Test</prosody><s>This is Test</s>' \
                            '<say-as format="" interpret-as="spell-out">This is Test</say-as>' \
                            '<sub alias="World Wide Web Consortium">This is Test</sub><w role="claws:VV0">' \
                            'This is Test</w></Speak></Response>'

        voice = 'Polly.Joey'
        language = 'en-US'
        loop = 1
        content = 'This is Test'

        content_break = 'This is Test'
        strength_break = 'strong'
        time_break = '250ms'

        content_lang = 'This is Test'
        xmllang_lang = "it"

        content_p = 'This is Test'

        content_emphasis = 'This is Test'
        level_emphasis = 'strong'

        content_phoneme = 'This is Test'
        alphabet_phoneme = "ipa"
        ph_phoneme = "t&#x259;mei&#x325;&#x27E;ou&#x325;"

        content_prosody = "This is Test"
        volume_prosody = "+6dB"
        rate_prosody = "x-high"
        pitch_prosody = "low"

        content_s = "This is Test"

        content_say_as = 'This is Test'
        interpret_as_say_as = "spell-out"
        format_say_as = ""

        content_sub = "This is Test"
        alias_sub = "World Wide Web Consortium"

        content_w = "This is Test"
        role_w = "claws:VV0"

        element = plivoxml.ResponseElement()
        response = element.add(
            plivoxml.SpeakElement(content).set_voice(voice).set_language(
                language
            ).set_loop(
                loop
            ).add_break(
                time=time_break
            ).add_emphasis(
                content_emphasis,
                level=level_emphasis
            ).add_lang(
                content_lang,
                xmllang=xmllang_lang
            ).add_p(
                content_p
            ).add_phoneme(
                content_phoneme,
                alphabet=alphabet_phoneme,
                ph=ph_phoneme
            ).add_prosody(
                content_prosody,
                volume=volume_prosody,
                rate=rate_prosody,
                pitch=pitch_prosody
            ).add_s(
                content_s
            ).add_say_as(
                content_say_as,
                interpret_as=interpret_as_say_as,
                format=format_say_as
            ).add_sub(
                content_sub,
                alias=alias_sub,
            ).add_w(
                content_w,
                role_w
            )
        ).to_string(False)
        self.assertEqual(response, expected_response)