Skip to content

Commit

Permalink
Merge pull request #549 from 10up/feature/540-audio-generation-displa…
Browse files Browse the repository at this point in the history
…y-optimization

#540 - Audio Generation Cleanup / Optimization / Display
  • Loading branch information
dkotter authored Aug 4, 2023
2 parents ec88b99 + efd11df commit 61e98ad
Show file tree
Hide file tree
Showing 13 changed files with 369 additions and 280 deletions.
13 changes: 4 additions & 9 deletions includes/Classifai/Admin/BulkActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Classifai\Providers\OpenAI\Whisper\Transcribe;
use function Classifai\get_post_types_for_language_settings;
use function Classifai\get_supported_post_types;
use function Classifai\get_tts_supported_post_types;

/**
* Handle bulk actions.
Expand Down Expand Up @@ -68,15 +69,14 @@ public function register() {
* Register bulk actions for language processing.
*/
public function register_language_processing_hooks() {
$this->chat_gpt = new ChatGPT( false );
$this->embeddings = new Embeddings( false );
$this->text_to_speech = new TextToSpeech( false );
$this->chat_gpt = new ChatGPT( false );
$this->embeddings = new Embeddings( false );

$user_roles = wp_get_current_user()->roles ?? [];
$embedding_settings = $this->embeddings->get_settings();
$embeddings_post_types = [];
$nlu_post_types = get_supported_post_types();
$text_to_speech_post_types = $this->text_to_speech->get_supported_post_types();
$text_to_speech_post_types = get_tts_supported_post_types();
$chat_gpt_post_types = [];
$chat_gpt_settings = $this->chat_gpt->get_settings();

Expand Down Expand Up @@ -104,11 +104,6 @@ public function register_language_processing_hooks() {
$this->embeddings = null;
}

// Clear our TextToSpeech handler if no post types are set up.
if ( empty( $text_to_speech_post_types ) ) {
$this->text_to_speech = null;
}

// Merge our post types together and make them unique.
$post_types = array_unique( array_merge( $chat_gpt_post_types, $embeddings_post_types, $nlu_post_types, $text_to_speech_post_types ) );

Expand Down
23 changes: 23 additions & 0 deletions includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Classifai;

use Classifai\Providers\Provider;
use Classifai\Providers\Azure;
use Classifai\Services\Service;
use Classifai\Services\ServicesManager;
use WP_Error;
Expand Down Expand Up @@ -275,6 +276,28 @@ function get_supported_post_types() {
return $post_types;
}

/**
* The list of post types that TTS supports.
*
* @return array Supported Post Types.
*/
function get_tts_supported_post_types() {
$classifai_settings = get_plugin_settings( 'language_processing', Azure\TextToSpeech::FEATURE_NAME );

if ( empty( $classifai_settings ) ) {
$post_types = [];
} else {
$post_types = [];
foreach ( $classifai_settings['post_types'] as $post_type => $enabled ) {
if ( ! empty( $enabled ) ) {
$post_types[] = $post_type;
}
}
}

return $post_types;
}

/**
* The list of post statuses that get the ClassifAI taxonomies. Defaults
* to 'publish'.
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/Azure/ComputerVision.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function reset_settings() {
*
* @return array
*/
private function get_default_settings() {
public function get_default_settings() {
return [
'valid' => false,
'url' => '',
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/Azure/Personalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function reset_settings() {
*
* @return array
*/
private function get_default_settings() {
public function get_default_settings() {
return [
'authenticated' => false,
'url' => '',
Expand Down
Loading

0 comments on commit 61e98ad

Please sign in to comment.