/AWS1/IF_PLY=>STARTSPEECHSYNTHESISSTREAM()¶
About StartSpeechSynthesisStream¶
Synthesizes UTF-8 input, plain text, or SSML over a bidirectional streaming connection. Specify synthesis parameters in HTTP/2 headers, send text incrementally as events on the input stream, and receive synthesized audio as it becomes available.
This operation serves as a bidirectional counterpart to SynthesizeSpeech:
Method Signature¶
METHODS /AWS1/IF_PLY~STARTSPEECHSYNTHESISSTREAM
IMPORTING
!IV_ENGINE TYPE /AWS1/PLYENGINE OPTIONAL
!IV_LANGUAGECODE TYPE /AWS1/PLYLANGUAGECODE OPTIONAL
!IT_LEXICONNAMES TYPE /AWS1/CL_PLYLEXICONNAMELIST_W=>TT_LEXICONNAMELIST OPTIONAL
!IV_OUTPUTFORMAT TYPE /AWS1/PLYOUTPUTFORMAT OPTIONAL
!IV_SAMPLERATE TYPE /AWS1/PLYSAMPLERATE OPTIONAL
!IV_VOICEID TYPE /AWS1/PLYVOICEID OPTIONAL
!IO_ACTIONSTREAM TYPE REF TO /AWS1/IF_PLYSTRTSPCSYNSTRMAC00 OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_plystartspcsynstrmout
RAISING
/AWS1/CX_PLYSERVICEFAILUREEX
/AWS1/CX_PLYSERVICEQUOTAEXCDEX
/AWS1/CX_PLYTHROTTLINGEX
/AWS1/CX_PLYVLDTNEXCEPTION
/AWS1/CX_PLYCLIENTEXC
/AWS1/CX_PLYSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_engine TYPE /AWS1/PLYENGINE /AWS1/PLYENGINE¶
Specifies the engine for Amazon Polly to use when processing input text for speech synthesis. Currently, only the
generativeengine is supported. If you specify a voice that the selected engine doesn't support, Amazon Polly returns an error.
iv_outputformat TYPE /AWS1/PLYOUTPUTFORMAT /AWS1/PLYOUTPUTFORMAT¶
The audio format for the synthesized speech. Currently, Amazon Polly does not support JSON speech marks.
iv_voiceid TYPE /AWS1/PLYVOICEID /AWS1/PLYVOICEID¶
The voice to use in synthesis. To get a list of available voice IDs, use the DescribeVoices operation.
Optional arguments:¶
iv_languagecode TYPE /AWS1/PLYLANGUAGECODE /AWS1/PLYLANGUAGECODE¶
An optional parameter that sets the language code for the speech synthesis request. Specify this parameter only when using a bilingual voice. If a bilingual voice is used and no language code is specified, Amazon Polly uses the default language of the bilingual voice.
it_lexiconnames TYPE /AWS1/CL_PLYLEXICONNAMELIST_W=>TT_LEXICONNAMELIST TT_LEXICONNAMELIST¶
The names of one or more pronunciation lexicons for the service to apply during synthesis. Amazon Polly applies lexicons only when the lexicon language matches the voice language.
iv_samplerate TYPE /AWS1/PLYSAMPLERATE /AWS1/PLYSAMPLERATE¶
The audio frequency, specified in Hz.
io_actionstream TYPE REF TO /AWS1/IF_PLYSTRTSPCSYNSTRMAC00 /AWS1/IF_PLYSTRTSPCSYNSTRMAC00¶
The input event stream that contains text events and stream control events.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_plystartspcsynstrmout /AWS1/CL_PLYSTARTSPCSYNSTRMOUT¶
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->startspeechsynthesisstream(
io_actionstream = lo_stream
it_lexiconnames = VALUE /aws1/cl_plylexiconnamelist_w=>tt_lexiconnamelist(
( new /aws1/cl_plylexiconnamelist_w( |string| ) )
)
iv_engine = |string|
iv_languagecode = |string|
iv_outputformat = |string|
iv_samplerate = |string|
iv_voiceid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
TRY.
WHILE lo_result->get_eventstream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
lo_event = lo_result->get_eventstream( )->READ( ).
IF lo_event->get_audioevent( ) IS NOT INITIAL.
" process this kind of event
ELSEIF lo_event->get_streamclosedevent( ) IS NOT INITIAL.
" process this kind of event
ENDIF.
ENDWHILE.
CATCH /aws1/cx_plyvldtnexception.
" handle error in stream
CATCH /aws1/cx_plythrottlingex.
" handle error in stream
CATCH /aws1/cx_plyservicequotaexcdex.
" handle error in stream
CATCH /aws1/cx_plyservicefailureex.
" handle error in stream
ENDTRY.
ENDIF.