Plugin Directory

Changeset 2218638


Ignore:
Timestamp:
12/27/2019 12:46:44 PM (6 years ago)
Author:
awslabs
Message:

trunk 4.0.2

Location:
amazon-polly/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • amazon-polly/trunk/README.md

    r2188605 r2218638  
    66| Requires at least | 3.0.1 |
    77| Requires PHP | 5.6 |
    8 | Tested up to | 5.2 |
    9 | Stable tag | 4.0.1 |
     8| Tested up to | 5.3 |
     9| Stable tag | 4.0.2 |
    1010| License | GPLv3 ONLY |
    1111| License URI | https://www.gnu.org/licenses/gpl-3.0.html |
     
    135135
    136136#### Changelog
     137
     138= 4.0.2 =
     139* Added translate support for multiple new languages
     140* Added Conversational Polly Style.
    137141
    138142= 4.0.1 =
  • amazon-polly/trunk/README.txt

    r2188605 r2218638  
    44Requires at least: 3.0.1
    55Requires PHP: 5.6
    6 Tested up to: 5.2
    7 Stable tag: 4.0.1
     6Tested up to: 5.3
     7Stable tag: 4.0.2
    88License: GPLv3 ONLY
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    134134
    135135== Changelog ==
     136
     137= 4.0.2 =
     138* Added translate support for multiple new languages
     139* Added Conversational Polly Style.
    136140
    137141= 4.0.1 =
  • amazon-polly/trunk/admin/AmazonAI-Common.php

    r2188605 r2218638  
    1313    // Information about languages supported by the AWS plugin
    1414    private $languages = [
     15
     16        ['code' => 'af', 'name' => 'Afrikaans', 'translatable' => '1', 'polly' => '0'],
     17        ['code' => 'sq', 'name' => 'Albanian', 'translatable' => '1', 'polly' => '0'],
     18        ['code' => 'am', 'name' => 'Amharic', 'translatable' => '1', 'polly' => '0'],
    1519        ['code' => 'ar', 'name' => 'Arabic', 'translatable' => '1', 'polly' => '1'],
     20        ['code' => 'az', 'name' => 'Azerbaijani', 'translatable' => '1', 'polly' => '0'],
     21        ['code' => 'bn', 'name' => 'Bengali', 'translatable' => '1', 'polly' => '0'],
     22        ['code' => 'bs', 'name' => 'Bosnian', 'translatable' => '1', 'polly' => '0'],
     23        ['code' => 'bg', 'name' => 'Bulgarian', 'translatable' => '1', 'polly' => '0'],
     24        ['code' => 'fr-CA', 'name' => 'Canadian French', 'translatable' => '1', 'polly' => '0'],
    1625        ['code' => 'da', 'name' => 'Danish', 'translatable' => '1', 'polly' => '1'],
    1726        ['code' => 'nl', 'name' => 'Dutch', 'translatable' => '1', 'polly' => '1'],
    1827        ['code' => 'zh', 'name' => 'Chinese', 'translatable' => '1', 'polly' => '1'],
    19         ['code' => 'cs', 'name' => 'Czech', 'translatable' => '1', 'polly' => ''],
     28        ['code' => 'hr', 'name' => 'Croatian', 'translatable' => '1', 'polly' => '0'],
     29        ['code' => 'cs', 'name' => 'Czech', 'translatable' => '1', 'polly' => '0'],
     30        ['code' => 'fa-AF', 'name' => 'Dari', 'translatable' => '1', 'polly' => '0'],
     31        ['code' => 'nl', 'name' => 'Dutch', 'translatable' => '1', 'polly' => '0'],
    2032        ['code' => 'en', 'name' => 'English', 'translatable' => '1', 'polly' => '1'],
     33        ['code' => 'et', 'name' => 'Estonian', 'translatable' => '1', 'polly' => '0'],
    2134        ['code' => 'fi', 'name' => 'Finish', 'translatable' => '1', 'polly' => ''],
    2235        ['code' => 'fr', 'name' => 'French', 'translatable' => '1', 'polly' => '1'],
     36        ['code' => 'ka', 'name' => 'Georgian', 'translatable' => '1', 'polly' => '0'],
    2337        ['code' => 'de', 'name' => 'German', 'translatable' => '1', 'polly' => '1'],
     38        ['code' => 'el', 'name' => 'Greek', 'translatable' => '1', 'polly' => '0'],
     39        ['code' => 'ha', 'name' => 'Hausa', 'translatable' => '1', 'polly' => '0'],
    2440        ['code' => 'he', 'name' => 'Hebrew', 'translatable' => '1', 'polly' => ''],
    2541        ['code' => 'hi', 'name' => 'Hindi', 'translatable' => '1', 'polly' => ''],
     42        ['code' => 'hu', 'name' => 'Hungarian', 'translatable' => '1', 'polly' => '0'],
    2643        ['code' => 'is', 'name' => 'Icelandic', 'translatable' => '0', 'polly' => '1'],
    2744        ['code' => 'it', 'name' => 'Italian', 'translatable' => '1', 'polly' => '1'],
     
    2946        ['code' => 'ja', 'name' => 'Japanese', 'translatable' => '1', 'polly' => '1'],
    3047        ['code' => 'ko', 'name' => 'Korean', 'translatable' => '1', 'polly' => '1'],
     48        ['code' => 'lv', 'name' => 'Latvian', 'translatable' => '1', 'polly' => '0'],
    3149        ['code' => 'ms', 'name' => 'Malay', 'translatable' => '1', 'polly' => ''],
    3250        ['code' => 'no', 'name' => 'Norwegian', 'translatable' => '1', 'polly' => '1'],
     
    3452        ['code' => 'pl', 'name' => 'Polish', 'translatable' => '1', 'polly' => '1'],
    3553        ['code' => 'pt', 'name' => 'Portuguese', 'translatable' => '1', 'polly' => '1'],
    36         ['code' => 'ro', 'name' => 'Romanian', 'translatable' => '', 'polly' => '1'],
     54        ['code' => 'ps', 'name' => 'Pushto', 'translatable' => '1', 'polly' => '0'],
     55        ['code' => 'ro', 'name' => 'Romanian', 'translatable' => '1', 'polly' => '1'],
     56        ['code' => 'sr', 'name' => 'Serbian', 'translatable' => '1', 'polly' => '0'],
     57        ['code' => 'sk', 'name' => 'Slovak', 'translatable' => '1', 'polly' => '0'],
     58        ['code' => 'sl', 'name' => 'Slovenian', 'translatable' => '1', 'polly' => '0'],
     59        ['code' => 'so', 'name' => 'Somali', 'translatable' => '1', 'polly' => '0'],
     60        ['code' => 'sw', 'name' => 'Swahili', 'translatable' => '1', 'polly' => '0'],
    3761        ['code' => 'ru', 'name' => 'Russian', 'translatable' => '1', 'polly' => '1'],
    3862        ['code' => 'es', 'name' => 'Spanish', 'translatable' => '1', 'polly' => '1'],
    3963        ['code' => 'sv', 'name' => 'Swedish', 'translatable' => '1', 'polly' => '1'],
     64        ['code' => 'tl', 'name' => 'Tagalog', 'translatable' => '1', 'polly' => '0'],
     65        ['code' => 'ta', 'name' => 'Tamil', 'translatable' => '1', 'polly' => '0'],
     66        ['code' => 'th', 'name' => 'Thai', 'translatable' => '1', 'polly' => '0'],
    4067        ['code' => 'tr', 'name' => 'Turkish', 'translatable' => '1', 'polly' => '1'],
     68        ['code' => 'uk', 'name' => 'Ukrainian', 'translatable' => '1', 'polly' => '0'],
     69        ['code' => 'ur', 'name' => 'Urdu', 'translatable' => '1', 'polly' => '0'],
     70        ['code' => 'vi', 'name' => 'Vietnamese', 'translatable' => '1', 'polly' => '0'],
    4171        ['code' => 'cy', 'name' => 'Welsh', 'translatable' => '', 'polly' => '1']
    4272    ];
     
    961991        $option_value = get_option('amazon_polly_news', '');
    962992        if (empty($option_value)) {
    963             return '';
     993            return false;
    964994        }
    965995        else {
     
    968998    }
    969999
     1000
     1001        public function is_polly_conversational_enabled() {
     1002
     1003            if (!$this->is_polly_neural_enabled()) {
     1004                return false;
     1005            }
     1006
     1007            if ($this->is_polly_news_enabled()) {
     1008                return false;
     1009            }
     1010
     1011            $option_value = get_option('amazon_polly_conversational', '');
     1012            if (empty($option_value)) {
     1013                return '';
     1014            }
     1015            else {
     1016                return ' checked ';
     1017            }
     1018        }
     1019
     1020        public function should_conversational_style_be_used($voice) {
     1021
     1022            if ( !$this->is_conversational_style_for_voice($voice)) {
     1023                return false;
     1024            }
     1025
     1026            if ($this->should_news_style_be_used($voice)) {
     1027                return false;
     1028            }
     1029
     1030            if ($this->is_polly_conversational_enabled()) {
     1031                $engine = $this->get_polly_engine($voice);
     1032                if ('neural' == $engine) {
     1033                    return true;
     1034                }
     1035                return false;
     1036            }
     1037
     1038            return false;
     1039        }
     1040
     1041
    9701042    public function should_news_style_be_used($voice) {
     1043
     1044        if ( !$this->is_news_style_for_voice($voice)) {
     1045            return false;
     1046        }
    9711047
    9721048        if ($this->is_polly_news_enabled()) {
     
    9821058
    9831059
     1060        public function is_conversational_supported_in_region() {
     1061
     1062            $selected_region = $this->get_aws_region();
     1063            $conversational_supported_regions = array("us-east-1","us-west-2","eu-west-1");
     1064
     1065            if (in_array($selected_region, $conversational_supported_regions)) {
     1066                return true;
     1067            } else {
     1068                return false;
     1069            }
     1070        }
     1071
    9841072    public function is_neural_supported_in_region() {
    9851073
     
    9941082    }
    9951083
     1084    public function is_news_style_for_voice($voice) {
     1085        $supported_voices = array("Joanna","Matthew");
     1086
     1087        if (in_array($voice, $supported_voices)) {
     1088            return true;
     1089        } else {
     1090            return false;
     1091        }
     1092    }
     1093
     1094    public function is_conversational_style_for_voice($voice) {
     1095        $supported_voices = array("Joanna","Matthew");
     1096
     1097        if (in_array($voice, $supported_voices)) {
     1098            return true;
     1099        } else {
     1100            return false;
     1101        }
     1102    }
    9961103
    9971104    public function is_neural_supported_for_voice($voice) {
    998         $neural_supported_voices = array("Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew");
     1105        $neural_supported_voices = array("Amy","Emma","Brian","Ivy","Joanna","Kendra","Kimberly","Salli","Joey","Justin","Matthew","Camila","Lupe");
    9991106
    10001107        if (in_array($voice, $neural_supported_voices)) {
  • amazon-polly/trunk/admin/AmazonAI-PollyConfiguration.php

    r2188605 r2218638  
    5656            if ($this->common->validate_amazon_polly_access()) {
    5757                if ($this->common->is_language_supported_for_polly()) {
     58                  add_settings_field( 'amazon_polly_voice_id', __( 'Voice name:', 'amazonpolly' ), array( $this, 'voices_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_voice_id' ) );
     59                  register_setting('amazon_ai_polly', 'amazon_polly_voice_id');
     60
    5861                    add_settings_field( 'amazon_polly_neural', __( 'Neural Text-To-Speech:', 'amazonpolly' ), array( $this, 'neural_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_neural' ) );
    5962                    register_setting('amazon_ai_polly', 'amazon_polly_neural');
    6063                    add_settings_field( 'amazon_polly_news', __( 'Newscaster Style:', 'amazonpolly' ), array( $this, 'news_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_news' ) );
    6164                    register_setting('amazon_ai_polly', 'amazon_polly_news');
     65                    add_settings_field( 'amazon_polly_conversational', __( 'Conversational Style:', 'amazonpolly' ), array( $this, 'conversational_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_conversational' ) );
     66                    register_setting('amazon_ai_polly', 'amazon_polly_conversational');
    6267                    add_settings_field( 'amazon_polly_sample_rate', __('Sample rate:', 'amazonpolly'), array($this,'sample_rate_gui'), 'amazon_ai_polly', 'amazon_ai_polly', array('label_for' => 'amazon_polly_sample_rate'));
    63                     add_settings_field( 'amazon_polly_voice_id', __( 'Voice name:', 'amazonpolly' ), array( $this, 'voices_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_voice_id' ) );
    6468                    add_settings_field( 'amazon_polly_auto_breaths', __( 'Automated breaths:', 'amazonpolly' ), array( $this, 'auto_breaths_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_auto_breaths_id' ) );
    6569                    add_settings_field( 'amazon_polly_ssml', __( 'Enable SSML support:', 'amazonpolly' ), array( $this, 'ssml_gui' ), 'amazon_ai_polly', 'amazon_ai_polly', array( 'label_for' => 'amazon_polly_ssml' ) );
     
    96100
    97101                    register_setting('amazon_ai_polly', 'amazon_polly_sample_rate');
    98                     register_setting('amazon_ai_polly', 'amazon_polly_voice_id');
    99102                    register_setting('amazon_ai_polly', 'amazon_polly_auto_breaths');
    100103                    register_setting('amazon_ai_polly', 'amazon_polly_ssml');
     
    305308     */
    306309    public function neural_gui() {
     310
     311      $voice_id   = $this->common->get_voice_id();
     312      if ( $this->common->is_neural_supported_for_voice($voice_id) ) {
    307313        if ($this->common->is_neural_supported_in_region()) {
    308314            echo '<input type="checkbox" name="amazon_polly_neural" id="amazon_polly_neural" ' . $this->common->is_polly_neural_enabled() . '> ';
     
    311317            echo '<p class="description" for="amazon_polly_news">Option not supported in this region</p>';
    312318        }
     319      } else {
     320        echo '<p class="description" for="amazon_polly_news">Option not supported for this voice</p>';
     321      }
     322
    313323    }
    314324
     
    318328     */
    319329    public function news_gui() {
    320         if ($this->common->is_neural_supported_in_region()) {
     330
     331      if ($this->common->is_neural_supported_in_region()) {
     332        if ($this->common->is_polly_neural_enabled()) {
     333          $voice_id = $this->common->get_voice_id();
     334          if ( $this->common->is_news_style_for_voice($voice_id) ) {
    321335            echo '<input type="checkbox" name="amazon_polly_news" id="amazon_polly_news" ' . $this->common->is_polly_news_enabled() . '> ';
    322             echo '<p class="description" for="amazon_polly_news">Newscaster Style. Available only when Neural Text-To-Speech is enabled and only for the Matthew and Joanna voices.</p>';
     336          } else {
     337            echo '<p class="description" for="amazon_polly_news">Option not supported for this voice</p>';
     338          }
    323339        } else {
    324             echo '<p class="description" for="amazon_polly_news">Option not supported in this region</p>';
    325         }
     340          echo '<p class="description" for="amazon_polly_news">Neural needs to be enabled</p>';
     341        }
     342      } else {
     343        echo '<p class="description" for="amazon_polly_news">Option not supported in this region</p>';
     344      }
     345    }
     346
     347    /**
     348     * Render the Conversational GUI
     349     *
     350     */
     351    public function conversational_gui() {
     352
     353      if ($this->common->is_neural_supported_in_region()) {
     354        if ($this->common->is_polly_neural_enabled()) {
     355          $voice_id = $this->common->get_voice_id();
     356          if ( $this->common->is_conversational_style_for_voice($voice_id) ) {
     357            if ( !$this->common->is_polly_news_enabled()) {
     358              echo '<input type="checkbox" name="amazon_polly_conversational" id="amazon_polly_conversational" ' . $this->common->is_polly_conversational_enabled() . '> ';
     359            } else {
     360              echo '<p class="description" for="amazon_polly_conversational">Only one style can be used</p>';
     361            }
     362          } else {
     363            echo '<p class="description" for="amazon_polly_conversational">Option not supported for this voice</p>';
     364          }
     365        } else {
     366          echo '<p class="description" for="amazon_polly_conversational">Neural needs to be enabled</p>';
     367        }
     368      } else {
     369        echo '<p class="description" for="amazon_polly_conversational">Option not supported in this region</p>';
     370      }
     371
    326372    }
    327373
  • amazon-polly/trunk/admin/AmazonAI-PollyService.php

    r2188605 r2218638  
    335335            $text_content = $this->add_mark_tag($common, $text_content);
    336336
    337             // Adding newscaster style tag
    338             $text_content = $this->add_newscaster_tag($common, $text_content, $voice_id);
     337      // Adding newscaster style tag
     338            $text_content = $this->add_newscaster_tag($common, $text_content, $voice_id);
     339
     340            // Adding conversational style tag
     341            $text_content = $this->add_conversational_tag($common, $text_content, $voice_id);
    339342
    340343            // Adding speak polly mark.
     
    350353      //Detect Polly Engine (Standard / Neural).
    351354      $engine = $common->get_polly_engine($voice_id);
    352       $news = $common->should_news_style_be_used($voice_id);
     355      $news_style = $common->should_news_style_be_used($voice_id);
     356            $conversational_style = $common->should_conversational_style_be_used($voice_id);
    353357
    354358            $logger->log(sprintf('%s Final Polly text:', __METHOD__));
     
    357361            $logger->log(sprintf('%s Voice: %s ', __METHOD__, $voice_id));
    358362            $logger->log(sprintf('%s SampleRate: %s ', __METHOD__, $sample_rate));
     363            $logger->log(sprintf('%s News Style Enabled: %s ', __METHOD__, $news_style));
     364            $logger->log(sprintf('%s Conversational Style Enabled: %s ', __METHOD__, $conversational_style));
    359365
    360366
     
    498504        if ($common->should_news_style_be_used($voice)) {
    499505            $text_content = '<amazon:domain name="news">' . $text_content . '</amazon:domain>';
     506        }
     507        return $text_content;
     508    }
     509
     510        private function add_conversational_tag($common, $text_content, $voice) {
     511        if ($common->should_conversational_style_be_used($voice)) {
     512            $text_content = '<amazon:domain name="conversational">' . $text_content . '</amazon:domain>';
    500513        }
    501514        return $text_content;
  • amazon-polly/trunk/admin/AmazonAI-TranslateConfiguration.php

    r2188605 r2218638  
    183183
    184184
    185         $only_labels = array("ar", "fa", "hi", "ms");
     185        $only_labels = array("af","am","bn","bs","fa-AF","ha","ps","so","sw","tl","ta","ur","sr","ar", "fa", "hi", "ms");
    186186        if ( in_array($lanuage, $only_labels) ) {
    187187            $display_values   = [ 'Label' ];
  • amazon-polly/trunk/amazonpolly.php

    r2188605 r2218638  
    1717 * Plugin URI:        https://wordpress.org/plugins/amazon-polly/
    1818 * Description:       Create audio versions of your posts, translate them into other languages, and create podcasts. Integrate with Amazon Alexa to listen to your posts on Alexa-enabled devices. Use Amazon CloudFront to accelerate your website and provide a faster, more reliable viewing experience.
    19  * Version:           4.0.1
     19 * Version:           4.0.2
    2020 * Author:            AWS Labs, WP Engine
    2121 * Author URI:        https://aws.amazon.com/
Note: See TracChangeset for help on using the changeset viewer.