Skip to Content

It was friday , A famous day where people look at their watch 3 times more than often.

And techie like us try some R & D.

for me Last friday , target was OLE statements :

If you are not sure what is OLE , then let me tell you in short: its used to talk with presentation server. The ABAP processor normally buffers all successive OLE statements and sends them in a bundle to the presentation server and it will be executed there. Like : speech , excel integration etc..

For Text to Speech i created an object :

create object voice ‘SAPI.SpVoice’.

which is used while calling a method “Voice”.(which converts the Text to speech )

The Report which i created had a simple selection screen for a meeting request.

Like : meeting name

          Date

          Start time & End Time.

and a validation : “meeting Start time should be less than meeting EndTime”.

Copy paste the below report , and try entering meeting End Time less than meeting Start time.

this time with a normal error message display you can hear the error message too.

 
*&———————————————————————*
*& Report  ZTST_SCHEDULE_MEETING
*&
*&———————————————————————*
* copy the text elements
*P_DATE   Date
*P_MEND  Meeting End
*P_MNAME  Meeting name
*P_MST    Meeting Start
*&
*&———————————————————————*
report ztst_schedule_meeting.
tables : zmeetings.
include ole2incl.
parameters : p_mname type char20.
parameters : p_date type dats.
parameters : p_mst type syuzeit.
parameters : p_mend type syuzeit.
data : ole type ole2_object,
voice type ole2_object,
text   type string.
data : lv_time type t.

at selection-screen.
create object voice ‘SAPI.SpVoice’.
if p_mend < p_mst.
text = ‘Meeting Start time should be less than meeting End Time.’.
call method of voice ‘Speak’ = ole

exporting #1 = text.
  message ‘meeting Start time should be less than meeting End Time’ type ‘E’.
  endif.

To report this post you need to login first.

8 Comments

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

            1. Raju Borda Post author

              Hi Abhishek,

              I was checking it.But i think there are no parameters are provided where we can change the frequency of the voice .. may be need to go more at system level coding to change it .. 😉

              Thanks

              ~Raj

              (0) 
              1. Marco Sauro
                Hello,
                this code, that in VBS works, not works in ABAP, the problems seems that you can’t set parameters of the object with another object in OLE2 SAP.
                This code choose the voice, and download as VAW file in the file-system:

                  data spvoice type ole2_object.

                  data sptocket type ole2_object.

                  data sptocket_it type ole2_object.

                  data sptocket_all type ole2_object.

                  data spfilestream type ole2_object.
                  data lc_sdescription type string.
                  data icount type i value 0.
                  create object spvoice ‘SAPI.SpVoice’.
                  create object sptocket_all ‘SAPI.SpObjectToken’.
                  create object sptocket ‘SAPI.SpObjectToken’.
                  create object spfilestream ‘SAPI.SpFileStream’.

                  get property of spvoice ‘GetVoices’ = sptocket_all.

                  do 10 times.

                    clear lc_sdescription.

                    free sptocket.

                    get property of sptocket_all ‘Item’ = sptocket exporting #1 = icount.

                    get property of sptocket ‘GetDescription’ = lc_sdescription.

                    if lc_sdescription is initial.

                      exit.

                    endif.

                    if lc_sdescription CS ‘Anna’.

                *    DOESN’T WORK, IN VBS THE FOLLOW ISTRUCTION WORKS
                      SET PROPERTY OF spvoice ‘Voice’  = sptocket.
                      exit.
                    endif.
                  icount = icount + 1.
                  enddo.
                  if not lc_sdescription CS ‘Anna’.

                    raise no_voice_found.

                  endif.

                    call method of spfilestream ‘Open’ exporting #1 = ‘c:\temp\zcrm008_attenzione5.wav’
                                                                 #2 = 3.
                *    DOESN’T WORK, IN VBS THE FOLLOW ISTRUCTION WORKS
                    set property of spvoice ‘AudioOutputStream’ = spfilestream.
                    call method of spvoice ‘Speak’ exporting #1 = sleggi.
                    call method of spfilestream ‘Close’.

                (0) 
  1. Mehmet Emin Sahin

    http://www.tricktresor.de/blog/speak/

     

    for SAPI.SpVoice properties:

    https://msdn.microsoft.com/en-us/library/ms723609(v=vs.85).aspx

     

    also play voice file etc. .WAV file.

    TYPE-POOLS OLE2.
    data: VOICE_API type OLE2_OBJECT,
          DING_STRM type OLE2_OBJECT,
          l_ole type OLE2_OBJECT.
    
    
    data: strmFormat type ole2_object,
          tt type int4 .
    
    create object VOICE_API 'SAPI.SpVoice'.
     if sy-subrc ne 0.
       " 'SAPI.SpVoice OLE create error'.
     endif.
    
    create object DING_STRM 'SAPI.SpFileStream'.
     if sy-subrc ne 0.
       "'SAPI.SpFileStream OLE create error'.
     endif.
    
     call method of DING_STRM 'Open'
     exporting
     #1 = 'C:\Ding.wav'
     #2 = 0 . "SSFMOpenForRead = 0
    
     get property of DING_STRM 'Format' = strmFormat.
     get property of strmFormat 'Type' = tt.
     call function 'FLUSH'.
    
     if tt eq 0.
       "'Ding.wav file load error'.
     endif.
    
     call method of VOICE_API 'SpeakStream' = l_ole
     exporting
     #1 = DING_STRM
     #2 = 3. "SVSFlagsSync = 0 SVSFlagsAsync = 1 SVSFPurgeBeforeSpeak = 2
     call function 'FLUSH'.
    
    
    

     

    (0) 

Leave a Reply