9
9
namespace Classifai \Providers \AWS ;
10
10
11
11
use Classifai \Providers \Provider ;
12
- use Classifai \Normalizer ;
13
12
use Classifai \Features \TextToSpeech ;
14
13
use WP_Error ;
15
14
use Aws \Sdk ;
@@ -18,14 +17,6 @@ class AmazonPolly extends Provider {
18
17
19
18
const ID = 'aws_polly ' ;
20
19
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
-
29
20
/**
30
21
* AmazonPolly Text to Speech constructor.
31
22
*
@@ -374,12 +365,10 @@ public function synthesize_speech( int $post_id ) {
374
365
);
375
366
}
376
367
377
- $ normalizer = new Normalizer ();
378
368
$ feature = new TextToSpeech ();
379
369
$ 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 );
383
372
$ saved_attachment_id = (int ) get_post_meta ( $ post_id , $ feature ::AUDIO_ID_KEY , true );
384
373
385
374
// 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 ) {
453
442
$ polly_client = $ this ->get_polly_client ();
454
443
$ result = $ polly_client ->synthesizeSpeech ( $ synthesize_data );
455
444
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 ) );
457
446
$ contents = $ result ['AudioStream ' ]->getContents ();
458
447
return $ contents ;
459
448
} catch ( \Exception $ e ) {
0 commit comments