Skip to content

Add new "On Demand Mode" for Text to Speech processing#1125

Open
dkotter wants to merge 8 commits into
developfrom
feature/on-demand-tts
Open

Add new "On Demand Mode" for Text to Speech processing#1125
dkotter wants to merge 8 commits into
developfrom
feature/on-demand-tts

Conversation

@dkotter

@dkotter dkotter commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Description of the Change

When the Text to Speech Feature is turned on, there are two "modes" currently: generate speech automatically when content is saved or require generation to be manually turned on at the post level first (so kind of automatic vs manual though both fire on save, there isn't an actual manual button you can press).

This PR introduces a new mode: on-demand. The idea here is to avoid generating speech for posts that no one is going to listen to (and thus costing you more for no reason). As a good example, if you have a large backlog of content that doesn't yet have speech generated, instead of generating speech for all of that upfront, you can generate it on-demand as a user requests it.

With this new mode turned on, the audio controls will show on the front-end and the first time a user clicks to listen, it will make a request to generate the audio first. After it's generated once, that audio is stored and re-used for any subsequent requests so unless the content changes, audio is only generated on-demand once.

Couple things to keep in mind:

  1. This does mean the first time a user wants to listen to a post they'll have to wait for audio to generate. For longer posts, this could be 30 seconds or more
  2. Because this is a front-end generation, we can't limit based on users being logged in. This does open the door for someone to trigger audio generation on a bunch of posts and thus lead to a large amount of usage. We don't allow multiple generation requests per post and we don't generate audio if it already exists so the most impact you'd see is one generation request per post. This may be a dealbreaker for merging this in, though I don't see this as being any different from automatically generating audio for each post
  3. There's a chance on a high traffic site for multiple users to request audio at the same time. We do have protection in place to only generate once but for any users that try generating while a previous generation is happening, they'll get an error message until generation is done

Screenshot and screenshare

New audio generation settings
on-demand-tts.1.mov

How to test the Change

  1. Checkout this PR and run npm i && npm run build
  2. Turn on the Text to Speech Feature and choose the new On demand Audio generation mode
  3. Create a new post and ensure the audio generation toggle is on in the sidebar
  4. Publish this post and go to the front-end
  5. Ensure the audio controls show
  6. Click the play button and ensure you get a loading indicator
  7. Ensure once that is done the audio plays
  8. Refresh the page, click the play button again and ensure this runs immediately
  9. If desired, create a new post and turn off the audio generation toggle
  10. Ensure the audio controls don't show for that post

Changelog Entry

Added - On demand generation mode for Text to Speech. When enabled, TTS is never run automatically on publish but is only run when the audio is requested on the front-end by a user.

Credits

Props @dkotter

Checklist:

Open WordPress Playground Preview

@dkotter dkotter added this to the 3.9.0 milestone Jun 23, 2026
@dkotter dkotter self-assigned this Jun 23, 2026
@dkotter dkotter requested review from a team and jeffpaul as code owners June 23, 2026 23:11
@github-actions github-actions Bot added the needs:code-review This requires code review. label Jun 23, 2026
@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant