Snippets

Merkulove Team [Speaker]Madara chapters voicing

Created by Dmitry Merkulov
public function madara_chapters_voicing(){

    /** Security Check. */
    check_ajax_referer( 'speaker-nonce', 'nonce' );

    /** Current post attributes */
    $post_id = (int)$_POST['post_id'];
    $post_type = get_post_type( $post_id );

    if ( $post_type !== 'wp-manga' ) {

        \Merkulove\Speaker\SpeakerCaster::get_instance()->gspeak();

    } else {

        /** Get content, send for voicing, glue chapters, and save result files */
        $voice_acting = \Merkulove\Speaker\SpeakerCaster::get_instance()->voice_acting(

            $post_id, // Post id to which this post will be related
            'custom-content',
            [
                get_post( 33 )->post_content, // First chapter content
                get_post( 34 )->post_content, // Second chapter content
            ]

        );

        /** Return processing results to JS */
        wp_send_json( $voice_acting ?
            [
                'success' => true,
                'message' => esc_html__( 'Audio Generated Successfully', 'speaker' )
            ] :
            [
                'success' => false,
                'message' => esc_html__( 'An error occurred while generating the audio.', 'speaker' )
            ]
        );

    }

}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.