def step3(): builder = Builder() speak = Speak( 'You will be entered into a conference call now. You can initiate more calls to join participants or hangup to leave' ) conf = Conference(room='SDKTestConference') builder.add(speak).add(conf) return str(builder)
def find_me_or_follow_me(first: str, second: str): builder = Builder() dial = Dial(destination=first, timeout=12, strategy=DialStrategy.sequence, target_type=DialTargetType.number, attrib_timeout=6) dial.add(destination=second, target_type=DialTargetType.number, timeout=6) builder.add(dial) return str(builder)
def test_xml_builder(self): expected = "<document><work/></document>" xmlbuilder = Builder() result = etree.tostring( xmlbuilder.root, encoding='utf-8').decode('utf-8') self.assertEqual(expected, result)
def intro(localurl): builder = Builder() ringback = Ringback(file=f'{localurl}/apidazeintro.wav') wait8 = Wait(8) answer = Answer() record = Record(name='example_recording') wait = Wait(delay=2) playback = Playback(file=f'{localurl}/apidazeintro.wav') speak = Speak( text= 'This example script will show you some things you can do with our API' ) builder.add(ringback).add(wait).add(answer).add(record).add(wait).add( playback).add(speak).add(wait) speak = Speak( text= 'Press 1 for an example of text to speech, press 2 to enter an echo line to check voice latency or press 3 to enter a conference.', input_timeout=10000) bind1 = Bind(action=f'{localurl}/step1.xml', text='1') bind2 = Bind(action=f'{localurl}/step2.xml', text='2') bind3 = Bind(action=f'{localurl}/step3.xml', text='3') speak.add(bind1).add(bind2).add(bind3) builder.add(speak) return str(builder)
def test_xml_builder_example(self): expected = """ <document> <work> <answer/> <speak lang="en-US">Hello</speak> <echo>500</echo> </work> </document> """.replace('\n', '') xmlbuilder = Builder() answer = Answer() speak = Speak(text='Hello') echo = Echo(500) xmlbuilder.add(answer).add(speak).add(echo) result = etree.tostring( xmlbuilder.root, encoding='utf-8').decode('utf-8') self.assertEqual(expected, result)
def example_1(): xmlbuilder = Builder() answer = Answer() speak = Speak(text='Thank you for trying our demo. Have an wonderful day!') echo = Echo(500) xmlbuilder.add(answer).add(speak).add(echo) xmlbuilder.printXML()
def example_2(): xmlbuilder = Builder() answer = Answer() speak = Speak(text='Thank you for trying our demo. Have an excellent day!') record = Record(name='my_recording.wav') wait = Wait(delay=5) hangup = Hangup() xmlbuilder.add(answer).add(speak).add(record).add(wait).add(hangup) xmlbuilder.printXML()
def step2(): builder = Builder() speak = Speak(text='You will now be joined to an echo line.') echo = Echo(500) builder.add(speak).add(echo) return str(builder)
def step1(): builder = Builder() speak = Speak( text= "Our text to speech leverages Google's cloud APIs to offer the best possible solution" ) wait1 = Wait(delay=1) builder.add(speak).add(wait1) speak = Speak( text= 'A wide variety of voices and languages are available. Here are just a few', lang=SpeakLanguages.en_AU) builder.add(speak).add(wait1) speak = Speak(lang=SpeakLanguages.fr_FR, text='Je peux parler français') builder.add(speak).add(wait1) speak = Speak(lang=SpeakLanguages.de_DE, text='Auch deutsch') builder.add(speak).add(wait1) speak = Speak(lang=SpeakLanguages.ja_JP, text='そして日本人ですら') builder.add(speak).add(wait1) speak = Speak( text= "You can see our documentation for a full list of supported languages and voices for them. We'll take you back to the menu for now." ) wait2 = Wait(2) builder.add(speak).add(wait2) return str(builder)