Tag Archives: Telekom Tropo

Transkription: Sprache in Text umwandeln

Oft habe ich mir gewünscht, dass die Nachrichten vom Anrufbeantworter per SMS oder Email bei mir eingehen: Am liebsten in Textform! Dann kann ich wichtige Teile wie z. B. Telefonnummern oder Datumsangaben gleich in elektronischer Form übernehmen. Dass das kein Hexenwerk ist, wissen wir spätestens seit Apple Siri (Speech Interpretation and Recognition Interface).

Aber schon vorher haben zahlreiche Systeme intensiv von Spracherkennung Gebrauch gemacht, darunter Videobearbeitungsprogramme wie Adobe Premiere und zahlreiche Sprachdialogsysteme. Um genau zu sein gibt es hier jedoch einen wesentlichen Unterschied: Sprachdialogsysteme versuchen normalerweise Schlüsselwörter zu erkennen, die Transkription möchte hingegen den gesamten Text erfassen. In vielen Fällen reicht ersteres (und ersteres funktioniert in der Praxis meist auch besser). Am allerbesten ist es natürlich, die Wahl zu haben!

Einen einfachen Einstieg in die hier verwendete Scripting API des Cloud-basierten interaktiven Sprachdialogsystem Telekom Tropo finden Sie hier im Blog.

Telekom Tropo bietet in der neuesten Version diese Wahl. Mit ask kann eine Frage gestellt und die Antwort mit Hilfe verschiedener Grammatiken ermittelt werden (keine Sorge, es gibt ganz einfache Grammatiken, die für die meisten Anwendungsfälle ausreichen):

JavaScript (Scripting API):

1
2
var result = ask("What's color? Choose red, blue or green.", {choices:"red, blue, green"}); 
say("You said " + result.value);

Dank der neuen Transkriptions-Funktion kann Gesprochenes wie ein eingehender Anruf aber auch komplett in Text verwandelt werden. Nur einen kleinen Trick muss man nutzen, damit es klappt: Die Transkription erwartet ein Ziel für die Aufzeichnung der Audiodaten (wahlweise FTP oder per http-Post), sollte jedoch keine Aufzeichnung sondern nur die Transkription erwünscht sein, kann man hier einfach irgendein Ziel als Platzhalter eingeben. Außerdem wird eine transcriptionOutURI als HTTP-Post Ziel für das Ergebnis benötigt, die alternativ auch die Verwendung von mailto zum senden einer Email erlaubt:

JavaScript (Scripting API):

1
2
3
4
5
6
7
say("Welcome to speed therapy!");
record("Tell us how you feel in one minute or less!", {    
   beep:true,    
   maxTime:600,
   recordURI:"http://fakeurl.com/", /* we cannot leave this parameter blank */
   transcriptionOutURI: "mailto:me@mymail.com",
});

Das war es schon. Einen Wehrmutstropfen gibt es jedoch: Die Transkription hier ist aktuell nur für Englisch erhältlich und auf eine Minute beschränkt. Für einen Anrufbeantworter oder das Hinterlassen von kurzen Nachrichten sollte das aber allemal genügen…

Initiate your first text message (SMS) via HTTP

Since a few days there is a Scripting API for the Interactive Voice Response System (IVR) called Telekom Tropo. Thanks to this API it is easy to start immediately scripting your text messages without the need of a self-maintained infrastructure: All you need is internet access (which you probably have while reading this article) and a phone capable receiving text messages (SMS).

1. Sign-in

02_login

To start your first IVR project you need to be registered and logged in at Developer Garden. You find a detailed description of this 3-step-process in my blog.

2. Activate Telekom Tropo

04_api_management

Once logged-in go to the “My Account” page and select the API Management to activate the Telekom Tropo usage.

3. Add an application

05_application_management

In this step you create your application. First select the Application Management. Please do not get confused because of the image above: I have already created a bunch off applications – in your case this dialog might be more or less empty.

06_add_application

Finally click on “Add a new application”. A dialog appears where you select the type of your application which indeed is Telekom Tropo here. Furthermore you can choose Scripting or Web API. For this tutorial I recommend Scripting, because no hosting is required by you. And don´t worry, you can change this setting at any time.

If you are curious about the differences between the new Scripting API and the legacy Web API, here are some facts:

  • Use Web API for your own hosting (as long as your hosting is basically capable of HTTP, JSON and XML)
  • Using the Scripting API the hosting and maintenance is done by Developer Garden (the Scripting API allows hosting up to 200 MByte).

Please see my Quickstart Telekom Tropo for more details on the Web API:

  1. Quickstart Telekom Tropo Web API: Hello World (German)
  2. Quickstart Telekom Tropo Web API: Text to speech and voices (German)
  3. Generic SMS and Voice service with Telekom Tropo Web API (English)

4. Create your code

09_edit_basic_settings

In the settings page of your application click on “Map a hosted file” to create, upload, edit or delete your code.

For testing purpose we use the sandbox mode. This mode is free of charge, but has some limitations: E.g. only 10 SMS per day are allowed and each SMS contains the text “SMS API by developergarden.com”.

07_create_hosted_file

Clicking on the “NEW” menu and selecting “create file” generates a code file of the language of your choice – therefore make sure to use the right suffix (e.g. .js for JavaScript). The Scripting API supports a couple of dynamic languages on top of Java:

  • Javascript – Rhino – 1.7_R1 / ECMA-262 Edition 3
  • Groovy – Groovy – 1.6.0
  • PHP Quercus – 4.0.14 (equivalent to PHP 5.3.2)
  • Python – Jython – 2.5.2 (equivalent to Python 2.5)
  • Ruby – JRuby – 1.6.1 (equivalent to Ruby 1.9)

After you have created the file, an editor opens. To be honest, this editor is very rudimentary, but sufficient for simple scenarios (if you do not like it, use your own editor instead and upload the file here).

The Scripting API supports most of the “standard” libraries provided with that language’s Java implementation as well as the Java API available in the underlying JDK. You can find more info here:

08_edit_hosted_file

In the screenshot above we use JavaScript, but the code for sending a text message (SMS) looks very similar in all available languages. Just use your favorite and paste it in the editor:

JavaScript:

message("Developer Garden rocks!", {
   to:"+14075550100",
   channel:"text",
   network:"SMS"
});

Ruby:

message "Developer Garden rocks!", { 
   :to => "+14075550100",
   :channel => "text",
   :network => "SMS"
};

PHP:

<?php
message("Developer Garden rocks!", array( 
   "to" => "+14075550100", 
   "channel" => "text",
   "network" => "SMS"
));
?>

Python:

message("Developer Garden rocks!", { 
   "to":"+14075550100", 
   "channel":"text",
   "network":"SMS"
})

Groovy:

message("Developer Garden rocks!", [ 
   "to":"+14075550100", 
   "channel":"text",
   "network":"SMS"
])

Finally submit your code and make sure to map the desired file clicking on “Map”.

5. Run your application

You have two options to use your application. Either call a certain phone number (which you have to assign first in the applications settings) or just call a URI via the Telekom Tropo Rest API. As long as you do not have a phone number to assign, we do the latter.

10_edit_advanced_settings

To initiate an outbound call or text message you need just two things: The URI for the used Rest API and a token to identify your application (for security reasons do not make the token public). The URI looks like:

https://tropo.developergarden.com/api/sessions?action=create&token=TOKEN

The token is available in your applications settings. There you can create a new token as well.

11_url_call

This URI now starts your application identified via the used token. And your application itself sends a text message to the given phone number. That´s it…

If you need further information or if you like to test an incoming call with a SIP client, please see the official Telekom Tropo documentation.

One Portal – Simplified registration process at Developer Garden

Since a few days there is a simplified registration process to get access to the Developer Garden services and APIs like Telekom Tropo – in most cases these offerings are still free for developers for testing purpose as long as used in the sandbox. And even in production mode only the usage will be charged (please check the pricing for more details).

Previously you had to register twice: At Developer Garden and Deutsche Telekom´s Developer Center. This hassle is gone: There is no need to maintain two accounts anymore, because those two accounts are now “married”. Hence it´s sufficient to register at Developer Garden only to get access to the services and APIs. And this process is damn easy.

1. Start registration

00_site

Click on “Register” at the top which starts the registration process.

As an alternative you can sign in via several authentication services also known as OpenID clicking on “Login”. Currently Facebook, Google, Telekom My Login and Windows Live are supported as identity providers. If you take this path, you will be asked for a few additional details like your name.

2. Minimum of information

01_register

The registration is easy and you only have to enter a minimum of information like your name (e.g. to use our forum), email (e.g. to verify your existence via so called confirmed opt-in – otherwise somebody else could register you) and a password. Please agree to terms of usage and prove you are a human due to entering the digits of the image (this is called CAPTCHA).

3. Confirm registration

As mentioned before, misuse of your personal data will be prevented via opt-in. Therefore an email is sent to the given email address. Click on the confirmation link inside this email to verify the email and the registration process is finished.

4. Start using Developer Garden services and APIs

03_account

Once you are registered (and logged in), you can activate and explore Developer Garden services and APIs via “My Account” at the top of the page…