Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh Amazon Polly menggunakan SDK untuk SAP ABAP
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS SDK untuk SAP ABAP dengan Amazon Polly.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanDeleteLexicon.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. lo_ply->deletelexicon( iv_name ). MESSAGE 'Lexicon deleted successfully.' TYPE 'I'. CATCH /aws1/cx_plylexiconnotfoundex. MESSAGE 'Lexicon not found.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat DeleteLexicondi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanDescribeVoices.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Only pass optional parameters if they have values IF iv_engine IS NOT INITIAL AND iv_language IS NOT INITIAL. oo_result = lo_ply->describevoices( iv_engine = iv_engine iv_languagecode = iv_language ). ELSEIF iv_engine IS NOT INITIAL. oo_result = lo_ply->describevoices( iv_engine = iv_engine ). ELSEIF iv_language IS NOT INITIAL. oo_result = lo_ply->describevoices( iv_languagecode = iv_language ). ELSE. oo_result = lo_ply->describevoices( ). ENDIF. MESSAGE 'Retrieved voice metadata.' TYPE 'I'. CATCH /aws1/cx_plyinvalidnexttokenex. MESSAGE 'The NextToken is invalid.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat DescribeVoicesdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanGetLexicon.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. oo_result = lo_ply->getlexicon( iv_name ). DATA(lo_lexicon) = oo_result->get_lexicon( ). IF lo_lexicon IS BOUND. DATA(lv_lex_name) = lo_lexicon->get_name( ). MESSAGE |Retrieved lexicon: { lv_lex_name }| TYPE 'I'. ENDIF. CATCH /aws1/cx_plylexiconnotfoundex. MESSAGE 'Lexicon not found.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat GetLexicondi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanGetSpeechSynthesisTask.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. oo_result = lo_ply->getspeechsynthesistask( iv_task_id ). DATA(lo_task) = oo_result->get_synthesistask( ). IF lo_task IS BOUND. DATA(lv_status) = lo_task->get_taskstatus( ). MESSAGE |Task status: { lv_status }| TYPE 'I'. ENDIF. CATCH /aws1/cx_plyinvalidtaskidex. MESSAGE 'Invalid task ID.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. CATCH /aws1/cx_plysynthesistsknotf00. MESSAGE 'Synthesis task not found.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat GetSpeechSynthesisTaskdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanListLexicons.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. oo_result = lo_ply->listlexicons( ). DATA(lt_lexicons) = oo_result->get_lexicons( ). DATA(lv_count) = lines( lt_lexicons ). MESSAGE |Found { lv_count } lexicons| TYPE 'I'. CATCH /aws1/cx_plyinvalidnexttokenex. MESSAGE 'Invalid NextToken.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat ListLexiconsdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanListSpeechSynthesisTasks.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Only pass optional parameters if they have values IF iv_max_results IS NOT INITIAL AND iv_status IS NOT INITIAL. oo_result = lo_ply->listspeechsynthesistasks( iv_maxresults = iv_max_results iv_status = iv_status ). ELSEIF iv_max_results IS NOT INITIAL. oo_result = lo_ply->listspeechsynthesistasks( iv_maxresults = iv_max_results ). ELSEIF iv_status IS NOT INITIAL. oo_result = lo_ply->listspeechsynthesistasks( iv_status = iv_status ). ELSE. oo_result = lo_ply->listspeechsynthesistasks( ). ENDIF. DATA(lt_tasks) = oo_result->get_synthesistasks( ). DATA(lv_count) = lines( lt_tasks ). MESSAGE |Found { lv_count } synthesis tasks| TYPE 'I'. CATCH /aws1/cx_plyinvalidnexttokenex. MESSAGE 'Invalid NextToken.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat ListSpeechSynthesisTasksdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanPutLexicon.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. lo_ply->putlexicon( iv_name = iv_name iv_content = iv_content ). MESSAGE 'Lexicon created successfully.' TYPE 'I'. CATCH /aws1/cx_plyinvalidlexiconex. MESSAGE 'Invalid lexicon.' TYPE 'E'. CATCH /aws1/cx_plylexiconsizeexcdex. MESSAGE 'Lexicon size exceeded.' TYPE 'E'. CATCH /aws1/cx_plymaxlexemelengthe00. MESSAGE 'Maximum lexeme length exceeded.' TYPE 'E'. CATCH /aws1/cx_plymaxlexiconsnoexc00. MESSAGE 'Maximum number of lexicons exceeded.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. CATCH /aws1/cx_plyunsuppedplsalpha00. MESSAGE 'Unsupported PLS alphabet.' TYPE 'E'. CATCH /aws1/cx_plyunsuppedplslangu00. MESSAGE 'Unsupported PLS language.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat PutLexicondi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanStartSpeechSynthesisTask.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Only pass optional parameters if they have values IF iv_lang_code IS NOT INITIAL AND iv_s3_key_prefix IS NOT INITIAL. oo_result = lo_ply->startspeechsynthesistask( iv_engine = iv_engine iv_outputformat = iv_audio_format iv_outputs3bucketname = iv_s3_bucket iv_outputs3keyprefix = iv_s3_key_prefix iv_text = iv_text iv_voiceid = iv_voice_id iv_languagecode = iv_lang_code ). ELSEIF iv_lang_code IS NOT INITIAL. oo_result = lo_ply->startspeechsynthesistask( iv_engine = iv_engine iv_outputformat = iv_audio_format iv_outputs3bucketname = iv_s3_bucket iv_text = iv_text iv_voiceid = iv_voice_id iv_languagecode = iv_lang_code ). ELSEIF iv_s3_key_prefix IS NOT INITIAL. oo_result = lo_ply->startspeechsynthesistask( iv_engine = iv_engine iv_outputformat = iv_audio_format iv_outputs3bucketname = iv_s3_bucket iv_outputs3keyprefix = iv_s3_key_prefix iv_text = iv_text iv_voiceid = iv_voice_id ). ELSE. oo_result = lo_ply->startspeechsynthesistask( iv_engine = iv_engine iv_outputformat = iv_audio_format iv_outputs3bucketname = iv_s3_bucket iv_text = iv_text iv_voiceid = iv_voice_id ). ENDIF. MESSAGE 'Speech synthesis task started.' TYPE 'I'. CATCH /aws1/cx_plyinvalids3bucketex. MESSAGE 'Invalid S3 bucket.' TYPE 'E'. CATCH /aws1/cx_plyinvalidssmlex. MESSAGE 'Invalid SSML.' TYPE 'E'. CATCH /aws1/cx_plylexiconnotfoundex. MESSAGE 'Lexicon not found.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. CATCH /aws1/cx_plytextlengthexcdex. MESSAGE 'Text length exceeded maximum.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat StartSpeechSynthesisTaskdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanSynthesizeSpeech.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Only pass optional language code if it has a value IF iv_lang_code IS NOT INITIAL. oo_result = lo_ply->synthesizespeech( iv_engine = iv_engine iv_outputformat = iv_output_fmt iv_text = iv_text iv_voiceid = iv_voice_id iv_languagecode = iv_lang_code ). ELSE. oo_result = lo_ply->synthesizespeech( iv_engine = iv_engine iv_outputformat = iv_output_fmt iv_text = iv_text iv_voiceid = iv_voice_id ). ENDIF. MESSAGE 'Speech synthesized successfully.' TYPE 'I'. CATCH /aws1/cx_plyinvalidssmlex. MESSAGE 'Invalid SSML.' TYPE 'E'. CATCH /aws1/cx_plylexiconnotfoundex. MESSAGE 'Lexicon not found.' TYPE 'E'. CATCH /aws1/cx_plyservicefailureex. MESSAGE 'Service failure occurred.' TYPE 'E'. CATCH /aws1/cx_plytextlengthexcdex. MESSAGE 'Text length exceeded maximum.' TYPE 'E'. ENDTRY.-
Untuk detail API, lihat SynthesizeSpeechdi AWS SDK untuk referensi SAP ABAP API.
-