Changeset 2218638
- Timestamp:
- 12/27/2019 12:46:44 PM (6 years ago)
- Location:
- amazon-polly/trunk
- Files:
-
- 7 edited
-
README.md (modified) (2 diffs)
-
README.txt (modified) (2 diffs)
-
admin/AmazonAI-Common.php (modified) (7 diffs)
-
admin/AmazonAI-PollyConfiguration.php (modified) (5 diffs)
-
admin/AmazonAI-PollyService.php (modified) (4 diffs)
-
admin/AmazonAI-TranslateConfiguration.php (modified) (1 diff)
-
amazonpolly.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
amazon-polly/trunk/README.md
r2188605 r2218638 6 6 | Requires at least | 3.0.1 | 7 7 | 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 | 10 10 | License | GPLv3 ONLY | 11 11 | License URI | https://www.gnu.org/licenses/gpl-3.0.html | … … 135 135 136 136 #### Changelog 137 138 = 4.0.2 = 139 * Added translate support for multiple new languages 140 * Added Conversational Polly Style. 137 141 138 142 = 4.0.1 = -
amazon-polly/trunk/README.txt
r2188605 r2218638 4 4 Requires at least: 3.0.1 5 5 Requires PHP: 5.6 6 Tested up to: 5. 27 Stable tag: 4.0. 16 Tested up to: 5.3 7 Stable tag: 4.0.2 8 8 License: GPLv3 ONLY 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 134 134 135 135 == Changelog == 136 137 = 4.0.2 = 138 * Added translate support for multiple new languages 139 * Added Conversational Polly Style. 136 140 137 141 = 4.0.1 = -
amazon-polly/trunk/admin/AmazonAI-Common.php
r2188605 r2218638 13 13 // Information about languages supported by the AWS plugin 14 14 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'], 15 19 ['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'], 16 25 ['code' => 'da', 'name' => 'Danish', 'translatable' => '1', 'polly' => '1'], 17 26 ['code' => 'nl', 'name' => 'Dutch', 'translatable' => '1', 'polly' => '1'], 18 27 ['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'], 20 32 ['code' => 'en', 'name' => 'English', 'translatable' => '1', 'polly' => '1'], 33 ['code' => 'et', 'name' => 'Estonian', 'translatable' => '1', 'polly' => '0'], 21 34 ['code' => 'fi', 'name' => 'Finish', 'translatable' => '1', 'polly' => ''], 22 35 ['code' => 'fr', 'name' => 'French', 'translatable' => '1', 'polly' => '1'], 36 ['code' => 'ka', 'name' => 'Georgian', 'translatable' => '1', 'polly' => '0'], 23 37 ['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'], 24 40 ['code' => 'he', 'name' => 'Hebrew', 'translatable' => '1', 'polly' => ''], 25 41 ['code' => 'hi', 'name' => 'Hindi', 'translatable' => '1', 'polly' => ''], 42 ['code' => 'hu', 'name' => 'Hungarian', 'translatable' => '1', 'polly' => '0'], 26 43 ['code' => 'is', 'name' => 'Icelandic', 'translatable' => '0', 'polly' => '1'], 27 44 ['code' => 'it', 'name' => 'Italian', 'translatable' => '1', 'polly' => '1'], … … 29 46 ['code' => 'ja', 'name' => 'Japanese', 'translatable' => '1', 'polly' => '1'], 30 47 ['code' => 'ko', 'name' => 'Korean', 'translatable' => '1', 'polly' => '1'], 48 ['code' => 'lv', 'name' => 'Latvian', 'translatable' => '1', 'polly' => '0'], 31 49 ['code' => 'ms', 'name' => 'Malay', 'translatable' => '1', 'polly' => ''], 32 50 ['code' => 'no', 'name' => 'Norwegian', 'translatable' => '1', 'polly' => '1'], … … 34 52 ['code' => 'pl', 'name' => 'Polish', 'translatable' => '1', 'polly' => '1'], 35 53 ['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'], 37 61 ['code' => 'ru', 'name' => 'Russian', 'translatable' => '1', 'polly' => '1'], 38 62 ['code' => 'es', 'name' => 'Spanish', 'translatable' => '1', 'polly' => '1'], 39 63 ['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'], 40 67 ['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'], 41 71 ['code' => 'cy', 'name' => 'Welsh', 'translatable' => '', 'polly' => '1'] 42 72 ]; … … 961 991 $option_value = get_option('amazon_polly_news', ''); 962 992 if (empty($option_value)) { 963 return '';993 return false; 964 994 } 965 995 else { … … 968 998 } 969 999 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 970 1042 public function should_news_style_be_used($voice) { 1043 1044 if ( !$this->is_news_style_for_voice($voice)) { 1045 return false; 1046 } 971 1047 972 1048 if ($this->is_polly_news_enabled()) { … … 982 1058 983 1059 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 984 1072 public function is_neural_supported_in_region() { 985 1073 … … 994 1082 } 995 1083 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 } 996 1103 997 1104 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"); 999 1106 1000 1107 if (in_array($voice, $neural_supported_voices)) { -
amazon-polly/trunk/admin/AmazonAI-PollyConfiguration.php
r2188605 r2218638 56 56 if ($this->common->validate_amazon_polly_access()) { 57 57 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 58 61 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' ) ); 59 62 register_setting('amazon_ai_polly', 'amazon_polly_neural'); 60 63 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' ) ); 61 64 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'); 62 67 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' ) );64 68 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' ) ); 65 69 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' ) ); … … 96 100 97 101 register_setting('amazon_ai_polly', 'amazon_polly_sample_rate'); 98 register_setting('amazon_ai_polly', 'amazon_polly_voice_id');99 102 register_setting('amazon_ai_polly', 'amazon_polly_auto_breaths'); 100 103 register_setting('amazon_ai_polly', 'amazon_polly_ssml'); … … 305 308 */ 306 309 public function neural_gui() { 310 311 $voice_id = $this->common->get_voice_id(); 312 if ( $this->common->is_neural_supported_for_voice($voice_id) ) { 307 313 if ($this->common->is_neural_supported_in_region()) { 308 314 echo '<input type="checkbox" name="amazon_polly_neural" id="amazon_polly_neural" ' . $this->common->is_polly_neural_enabled() . '> '; … … 311 317 echo '<p class="description" for="amazon_polly_news">Option not supported in this region</p>'; 312 318 } 319 } else { 320 echo '<p class="description" for="amazon_polly_news">Option not supported for this voice</p>'; 321 } 322 313 323 } 314 324 … … 318 328 */ 319 329 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) ) { 321 335 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 } 323 339 } 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 326 372 } 327 373 -
amazon-polly/trunk/admin/AmazonAI-PollyService.php
r2188605 r2218638 335 335 $text_content = $this->add_mark_tag($common, $text_content); 336 336 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); 339 342 340 343 // Adding speak polly mark. … … 350 353 //Detect Polly Engine (Standard / Neural). 351 354 $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); 353 357 354 358 $logger->log(sprintf('%s Final Polly text:', __METHOD__)); … … 357 361 $logger->log(sprintf('%s Voice: %s ', __METHOD__, $voice_id)); 358 362 $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)); 359 365 360 366 … … 498 504 if ($common->should_news_style_be_used($voice)) { 499 505 $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>'; 500 513 } 501 514 return $text_content; -
amazon-polly/trunk/admin/AmazonAI-TranslateConfiguration.php
r2188605 r2218638 183 183 184 184 185 $only_labels = array("a r", "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"); 186 186 if ( in_array($lanuage, $only_labels) ) { 187 187 $display_values = [ 'Label' ]; -
amazon-polly/trunk/amazonpolly.php
r2188605 r2218638 17 17 * Plugin URI: https://wordpress.org/plugins/amazon-polly/ 18 18 * 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. 119 * Version: 4.0.2 20 20 * Author: AWS Labs, WP Engine 21 21 * Author URI: https://aws.amazon.com/
Note: See TracChangeset
for help on using the changeset viewer.