Morse Code

This guide dives into how to incorporate morse code into your XML bins.

We've set up a little demonstration for anyone interested in trying this out; reach out to 838-66-MORSE.

838-66-MORSE is powered by SignalWire Compatible XML using XML Bins, a server-less way to run your XML documents. As a way to help you get started, see the code below to form your own ASR --> Morse interface! We use the Say, Gather, and Redirect verbs as well as a bit more advanced functionality, SSML. We also incorporate a little Mustache templating!

1. Welcome to Morse
The below XML bin is based on the verb. Our narrator will begin by speaking in English and introduce the game that will be played. Notice that the verb is used to transition into the next XML bin in the call flow.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>
    <break strength="x-weak" time="200ms"/>
    <prosody pitch="+10%">In this day and age, some people forget where they came from. But not us here at Signal-Wire!</prosody> 
    <break strength="x-weak" time="300ms"/>
  </Say>
  <Say>
    <prosody pitch="+10%">To celebrate our heritage, let's kick this party <emphasis level="moderate">old-school style</emphasis> for a few minutes with some<say-as interpret-as="expletive">super cool</say-as> morse code.</prosody>
  </Say>
  <Redirect>https://morsecode.signalwire.com/laml-bins/d0234d15-6f4a-4f99-a0e6-9d6cbbf412cb</Redirect>;
</Response>

2. Let's get a name shall we?
Notice the usage of the verb to take in the caller's answer to 'What's your name?'

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Gather input="speech" speechTimeout="auto" action="https://morsecode.signalwire.com/laml-bins/e17a3ac4-fe21-427c-8796-e8ddadd98374">;
    <Say><break strength="x-weak" time="200ms"/><prosody pitch="+10%">Tell me: what's your name?</prosody></Say>
  </Gather>
</Response>

3. Let's play your name in Morse (with some Mustache templating to grab speech results)!
In this step, the verb is being amended with 'language="morse"'. This will translate our mustache variable {{SpeechResult}} into morse code and speak it back to us.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say><prosody pitch="+10%">So, {{SpeechResult}}, here is me saying your name in morse code:</prosody></Say>
  <Say language="morse">{{SpeechResult}}</Say>
  <Redirect method="GET">https://morsecode.signalwire.com/laml-bins/5e266f7b-526c-43ac-810d-2d82b5e43f22?name={{SpeechResult}}</Redirect>
</Response>

4. Now let's keep the fun going with speech recognition on full sentences!
The verb will now take in a larger speech input of a full sentence that the user would like translated. If nothing is said, the verb will terminate and the call will begin the process of ending.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Gather input="speech" speechTimeout="auto" action="https://morsecode.signalwire.com/laml-bins/db6ea71a-ac66-4207-a2cd-28803a68ffc9?name={{name}}">
    <say><prosody pitch="+10%">Speak whatever you want, and I'll say it in morse code.</prosody></Say>
  </Gather>
  <Say><prosody pitch="+10%">I suppose history means nothing to you {{name}}! Well then, good day sir!</prosody></Say>
</Response>

5. Speak the results.
The mustache variable {{SpeechResult}} was gathered from the user's speech entry and is now being repeated it back after translating into morse code.

If the user wishes to translate another sentence into morse code, they will be presented with the option to continue playing.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say><prosody pitch="+10%"">That would be:</prosody></Say>
  <Say language="morse" voice="woman">{{SpeechResult}}</Say>
  <Say><prosody pitch="+10%">I've waited years for this moment {{name}}. Let's keep it going.</prosody></Say>
  <Redirect>https://morsecode.signalwire.com/laml-bins/5e266f7b-526c-43ac-810d-2d82b5e43f22</Redirect>;
</response>

Sign Up Here

If you would like to test this example out, you can create a SignalWire account and space here.

Please feel free to reach out to us on our Community Slack or create a Support ticket if you need guidance!


Did this page help you?