Skip to content

Commit 76d83b7

Browse files
committed
Change a few things in the AWS Polly integration to take advantage of the changes made in the TTS feature, standardizing on how all these providers work
1 parent c890d8f commit 76d83b7

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

includes/Classifai/Providers/AWS/AmazonPolly.php

+3-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace Classifai\Providers\AWS;
1010

1111
use Classifai\Providers\Provider;
12-
use Classifai\Normalizer;
1312
use Classifai\Features\TextToSpeech;
1413
use WP_Error;
1514
use Aws\Sdk;
@@ -18,14 +17,6 @@ class AmazonPolly extends Provider {
1817

1918
const ID = 'aws_polly';
2019

21-
/**
22-
* Meta key to get/set the audio hash that helps to indicate if there is any need
23-
* for the audio file to be regenerated or not.
24-
*
25-
* @var string
26-
*/
27-
const AUDIO_HASH_KEY = '_classifai_post_audio_hash';
28-
2920
/**
3021
* AmazonPolly Text to Speech constructor.
3122
*
@@ -374,12 +365,10 @@ public function synthesize_speech( int $post_id ) {
374365
);
375366
}
376367

377-
$normalizer = new Normalizer();
378368
$feature = new TextToSpeech();
379369
$settings = $feature->get_settings();
380-
$post = get_post( $post_id );
381-
$post_content = $normalizer->normalize_content( $post->post_content, $post->post_title, $post_id );
382-
$content_hash = get_post_meta( $post_id, self::AUDIO_HASH_KEY, true );
370+
$post_content = $feature->normalize_post_content( $post_id );
371+
$content_hash = get_post_meta( $post_id, TextToSpeech::AUDIO_HASH_KEY, true );
383372
$saved_attachment_id = (int) get_post_meta( $post_id, $feature::AUDIO_ID_KEY, true );
384373

385374
// Don't regenerate the audio file it it already exists and the content hasn't changed.
@@ -453,7 +442,7 @@ public function synthesize_speech( int $post_id ) {
453442
$polly_client = $this->get_polly_client();
454443
$result = $polly_client->synthesizeSpeech( $synthesize_data );
455444

456-
update_post_meta( $post_id, self::AUDIO_HASH_KEY, md5( $post_content ) );
445+
update_post_meta( $post_id, TextToSpeech::AUDIO_HASH_KEY, md5( $post_content ) );
457446
$contents = $result['AudioStream']->getContents();
458447
return $contents;
459448
} catch ( \Exception $e ) {

0 commit comments

Comments
 (0)