Extend or customize TTSWP with standard WordPress hooks. Add these to your theme's functions.php or a custom plugin. Every hook is stable and documented.
Filter hooks
Modify the text before synthesis
Use this to clean up content, inject custom markup, or remove sections before audio is generated.
add_filter( 'mementor_tts_pre_synthesize_text', function( $text, $post_id ) {
// Your modifications
$text = str_replace( 'WP', 'WordPress', $text );
return $text;
}, 10, 2 );
Skip audio for specific posts
Return true to skip a post from auto-generation.
add_filter( 'mementor_tts_skip_auto_generation', function( $skip, $post_id ) {
// Skip posts in the "archive" category
if ( has_category( 'archive', $post_id ) ) {
return true;
}
return $skip;
}, 10, 2 );
Change the cache key
Override how TTSWP generates its audio cache key. Useful for cases where you want different caching per user or per custom context.
add_filter( 'mementor_tts_audio_cache_key', function( $key, $text, $voice ) {
return $key . '_' . get_current_user_id();
}, 10, 3 );
Customize the default voice
Change which voice is used for specific posts.
add_filter( 'mementor_tts_voice_for_post', function( $voice_id, $post_id ) {
if ( get_post_type( $post_id ) === 'podcast' ) {
return 'my-podcast-voice-id';
}
return $voice_id;
}, 10, 2 );
Render column markup
Used by multi-language integrations to render custom column content on the posts list.
add_filter( 'mementor_tts_render_column', function( $rendered, $post_id, $audio_exists, $audio_url, $processing, $post_status ) {
// Return true after rendering your own markup to skip the default
return $rendered;
}, 10, 6 );
Action hooks
Before audio is generated
add_action( 'mementor_tts_before_generate', function( $post_id, $text, $voice ) {
// Log, notify, or prepare something
}, 10, 3 );
After audio is generated
add_action( 'mementor_tts_audio_generated', function( $post_id, $audio_url, $characters ) {
// Notify, update a custom field, push to an external queue
}, 10, 3 );
After audio is deleted
add_action( 'mementor_tts_audio_deleted', function( $post_id ) {
// Clean up related data
} );
On site connect
add_action( 'mementor_tts_site_connected', function( $site_token ) {
// Notify your team, send a welcome email, etc.
} );
Constants you can define
Define in wp-config.php:
Enable debug logging
define( 'MEMENTOR_TTS_DEBUG', true );
When set, verbose logs are written to wp-content/debug.log.
Override API endpoint
For staging or testing environments:
define( 'MEMENTOR_TTS_API_URL', 'https://staging.ttswp.com' );
Common customization recipes
Add a per-post voice picker to the block editor sidebar
The plugin already adds a TTS panel to the editor. You can extend it:
add_filter( 'mementor_tts_editor_sidebar_fields', function( $fields ) {
$fields[] = [
'key' => 'speaking_speed',
'label' => 'Speaking speed',
'type' => 'number',
];
return $fields;
} );
Send every generation to Slack
add_action( 'mementor_tts_audio_generated', function( $post_id, $audio_url, $characters ) {
wp_remote_post( 'https://hooks.slack.com/your-webhook', [
'body' => json_encode( [
'text' => sprintf( 'Generated %d chars for post %s: %s', $characters, get_the_title( $post_id ), $audio_url ),
] ),
] );
}, 10, 3 );
Stability promise
Hooks listed on this page are stable public API. We do not remove or rename them without at least one major version notice in the changelog and a deprecation warning for the prior major version.