# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

import oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
ai_speech_client = oci.ai_speech.AIServiceSpeechClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
synthesize_speech_response = ai_speech_client.synthesize_speech(
    synthesize_speech_details=oci.ai_speech.models.SynthesizeSpeechDetails(
        text="EXAMPLE-text-Value",
        is_stream_enabled=True,
        compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        configuration=oci.ai_speech.models.TtsOracleConfiguration(
            model_family="ORACLE",
            model_details=oci.ai_speech.models.TtsOracleTts1StandardModelDetails(
                model_name="TTS_1_STANDARD",
                voice_id="ocid1.test.oc1..<unique_ID>EXAMPLE-voiceId-Value"),
            speech_settings=oci.ai_speech.models.TtsOracleSpeechSettings(
                text_type="SSML",
                sample_rate_in_hz=28589,
                output_format="MP3",
                speech_mark_types=["WORD"])),
        audio_config=oci.ai_speech.models.TtsBaseAudioConfig(
            config_type="BASE_AUDIO_CONFIG",
            save_path="EXAMPLE-savePath-Value")),
    opc_request_id="HM4AOZNO9MN7IFIVCEUM<unique_ID>")

# Get the data from response
print(synthesize_speech_response.data)

Was this article helpful?