Conversational AI • Last Updated 5/10/2024

Build a Text-to-Speech App in 5 Minutes with TeXML

Watch the video to learn how to write a simple text-to-speech TeXML app using Telnyx Call Control in just a few lines of code.

By Pete Christianson

TeXML Translator Video Thumbnail

TeXML Translator allows you to build applications using Telnyx numbers — fast.

In this guide, you’ll learn how to write a simple text-to-speech TeXML app using Telnyx Call Control in just a few lines of code.

Check out this short video to see it in action:

Read the full guide:

First, follow our quickstart guide to create a Telnyx account, phone number and connection.

Step 1: Create an XML file containing TeXML call instructions

If you already have an XML call instruction file from another provider, skip to Step 3. TeXML Translator will seamlessly interpret your existing verbs and nouns.

If you don't have an existing file, Create an empty standard .xml file using your preferred editor. TeXML files contain the following items:

  • response element tag defining the body of the TeXML document
  • verb an XML tag denoting the action that you want Telnyx to take
  • response element the item for the action specified in the associated verb

    In this example, we want to our application to answer incoming calls, play some speech to the caller and hangup so we only need Say and Hangup.

Code Snippet TeXML

Step 2: Make your TeXML file accessible on the internet

In order to execute your TeXML file, it has to be available via the internet for Telnyx Call Control to execute. Upload the XML file to your own publicly accessible server or use a temporary file storage service such as https://uguu.se/ for this example.

Step 3: Configure your Telnyx connection to point at your TeXML file

In your Telnyx Mission Control Portal account created in Step 1:

  • Select Connections from the left-hand side navigation menu
  • Edit the Connection you created in Step 1 by clicking on the pencil icon in the right column
  • Ensure the Call Control tab is selected in the middle region of the popup window
  • Change the Implementation from Webhook to XML
  • For this example, change the XML Request Method to GET
  • Enter the URL for the XML file you made available via the internet in Step 3
  • Save All Changes

Step 4: Dial your Telnyx number

Using your favorite telephony client or your own device, dial the number you purchased in Step 1 which is connected to the connection we just configured. The call will answer automatically and you should hear your text-to-speech playing. It's that simple!

To start building applications fast with TeXML Translator, head to the Mission Control Portal or check out the full API docs in our Developer Center.

Questions on setup? Talk to our experts.

Share on Social

Related articles

Sign up and start building.