'; $check_status = get_post_meta( $post->ID, 'amazon_polly_enable', true ); if ( '1' === $check_status ) { $checked = 'checked'; $post_options_visibility = ''; } elseif ( '0' === $check_status ) { $checked = ''; $post_options_visibility = 'display:none'; } else { $default_configuration = get_option( 'amazon_polly_defconf' ); if ( 'Amazon Polly enabled' === $default_configuration ) { $checked = 'checked'; $post_options_visibility = ''; } else { $checked = ''; $post_options_visibility = 'display:none'; } } $sample_rate = get_post_meta( $post->ID, 'amazon_polly_sample_rate', true ); $global_sample_rate = get_option( 'amazon_polly_sample_rate' ); if ( strcmp( $sample_rate, '' ) === 0 ) { $sample_rate = '22050'; if ( '' !== $global_sample_rate ) { $sample_rate = $global_sample_rate; } } $voice_id = get_post_meta( $post->ID, 'amazon_polly_voice_id', true ); $global_voice_id = get_option( 'amazon_polly_voice_id' ); if ( 0 === strcmp( $voice_id, '' ) && '' !== $global_voice_id ) { $voice_id = $global_voice_id; } echo '

'; $sample_array = [ '22050', '16000', '8000' ]; echo '
'; echo '

Sample rate:

'; // Basic check to see if the AWS Credentials are valid. try { if ( empty( get_option( 'amazon_polly_access_key' ) ) ) { // Set AWS SDK settings. $aws_sdk_config = [ 'region' => 'us-east-1', 'version' => 'latest', ]; } else { $aws_sdk_config = [ 'region' => 'us-east-1', 'version' => 'latest', 'credentials' => [ 'key' => get_option( 'amazon_polly_access_key' ), 'secret' => get_option( 'amazon_polly_secret_key' ), ], ]; }//end if $sdk = new Aws\Sdk( $aws_sdk_config ); $client = $sdk->createPolly(); $voice_list = $client->describeVoices(); $disabled = ''; } catch ( Exception $e ) { $disabled = 'disabled'; echo 'Please verify your AWS Credentials are accurate
'; }//end try /** * Compare two voices for ordering purpose. * * @param string $voice1 First voice. * @param string $voice2 Second voice. * @since 1.0.0 */ function sort_voices( $voice1, $voice2 ) { return strcmp( $voice1['LanguageName'], $voice2['LanguageName'] ); } echo '

Voice name:

'; echo '

'; echo '
'; }