Skip to Content

When we were kids,  speaking-robots were only part of science fiction films. Little by little technology began to be closer and closer to us. Today it is not a surprise to watch on the news about a new robot. We can begin to play. Would you like to listen from your application server a spoken report?. Here we give some steps to accomplish that.

Creating a simple BSP application.

1. At SE80 transaction create a new BSP application.

2. Create a new page (click right button over the BSP

application object name, Create, Page, set “Page with Flow Logic” Page Type ).

image

image

3. In the layout of the new page copy this BSP code.

<%

  DATA uname TYPE usr03-bname.

  DATA user TYPE usr03.

 

  uname = sy-uname.

 

  CALL FUNCTION ‘SUSR_SHOW_USER_DETAILS’

      EXPORTING

          bname            = uname

          no_display       = ‘X’

      CHANGING

          user_usr03       = user. 

%>

hello <%=user-name1%>, <%=sy-host%> is talking to you

image

4. Save and Activate (the page and the application).

Downloading the Speech Synthesis Engine.

5. Download the FreeTTS Speech Synthesis Engine.
http://downloads.sourceforge.net/freetts/freetts-1.2.1-bin.zip

6. Unzip the downloaded file.

7. Copy the speech.properties file, from /freetts-1.2.1/ path ( in the directory where you unzipped the downloaded file ), to your Java home directory (ie C:\j2sdk1.4.2_13\jre\lib ).

Making the Java project.

8. Open the SAP Netweaver Developer Studio.

9. Create a new Java project (File, New, Project, Java, set project name).

10. Set the Java build settings ( At package explorer view, click right button over the project name, Properties, Java Build Path, Libraries, Add external jar, select the freetts.jar file inside the /freetts-1.2.1/lib path located in the directory where you unzipped the downloaded file ).

image

11. Create the main class ( At package explorer view, click right button over the project name, New, Class, set the package name, class name and check the create main method option ).

image

12. Add these import lines below the package line.

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.net.URL;

import java.net.URLConnection;

import com.sun.speech.freetts.Voice;

import com.sun.speech.freetts.VoiceManager;

image

13. Copy this code inside the main method.

          try {          

               

               VoiceManager voiceManager = VoiceManager.getInstance();

               Voice voice = voiceManager.getVoice(“kevin16”);

               voice.allocate();

               

               // CHANGE THESE VALUES *****************

               String strUrlBSP = “http://myappserver:8030/sap/bc/bsp/sap/ztest/test.htm“;

               String strUser = “user”;

               String strPassword = “password”;

               String strClient = “client”;               

               // ************************************

                              

               URL url = new URL(strUrlBSP);               

               

               URLConnection urlConn = url.openConnection();

               urlConn.addRequestProperty(“sap-user”,strUser);

               urlConn.addRequestProperty(“sap-password”,strPassword);

               urlConn.addRequestProperty(“sap-client”,strClient);

               InputStreamReader isr = new InputStreamReader(urlConn.getInputStream());

               

               BufferedReader in = new BufferedReader(isr);

               String inputLine;

     

               while ((inputLine = in.readLine()) != null) {               

                    voice.speak(inputLine);

               }

               in.close();          

               

               voice.deallocate();

          }

          catch (Exception ex){

               System.out.println( ex.getMessage() );

          }          

!https://weblogs.sdn.sap.com/weblogs/images/251678771/img7.JPG|height=320|alt=image|width=495|src=https://weblogs.sdn.sap.com/weblogs/images/251678771/img7.JPG|border=0!

14. Change the url for your BSP applicaction, set your user, password and client to access.

image

Showtime !!!

15. Get your headphones and run the application !! ( Run, Run As, Java Application ).

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

    1. Ignacio Hernández Post author
      Hi David,

      you have here a excellent interview to Ike Nassi ,

      SAP’s senior vice president for research, Americas.

      There, you can read about the newest things happening (CarsWeaver…PartsWeaver…).

      And of course, innovation can be everywhere…Palo Alto or some little garage in South America

      😉

      Best,
      Ignacio.

      (0) 
  1. Leo Sopicki
    This is a great idea.  My team probably won’t be able to try this for a long while (we go into our first ABAP class in about an hour), but I’m going to save this link.  Keep up the good work.
    (0) 
  2. Mihai Olaru
    Hello Ignacio,

    Very good article, I wonder whether there is something simlar but the other way round: voice commands.

    Say ‘Submit’ and the BSP form get submitted 🙂

    Mihai

    (0) 
  3. Mihai Olaru
    Hello Ignacio,

    Very good article, I wonder whether there is something simlar but the other way round: voice commands.

    Say ‘Submit’ and the BSP form gets submitted 🙂

    Mihai

    (0) 
  4. Sandip Agarwalla
    Hello Ignacio,
    Very Good article. I tried implementing the same, but getting an Exception,as “Server returned HTTP response code: 401 for URL”..

    What might be the problem? I tried running the BSP URl with the same user id/pwd , its running fine.

    Regards,
    Sandip

    (0) 

Leave a Reply