Skip to content

Add support for text to speech conversion - #42

Open
dkotter wants to merge 5 commits into
trunkfrom
feature/text-to-speech
Open

Add support for text to speech conversion#42
dkotter wants to merge 5 commits into
trunkfrom
feature/text-to-speech

Conversation

@dkotter

@dkotter dkotter commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

What?

Adds support for text to speech conversion

Why?

We currently have a TODO statement around adding support for text to speech so this PR implements that. This allows others to build out text to speech systems using this provider plugin.

How?

  • Introduce a new OpenAiTextToSpeechConversionModel that handles all requests to convert text to speech
  • Ensure this model is loaded when a TTS generation request is made
  • When determining which model capabilities we want for TTS, ensure we support the inline output file type

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Putting together a plan and executing on that plan. Plan reviewed and modified by me and all code was reviewed and tested by me

Testing Instructions

Hard to test on it's own as this plugin provides functionality but doesn't actually do anything with that. Easiest approach is the following:

  1. Checkout the WordPress AI plugin from this PR
  2. Download this PR, activate and configure the OpenAI Provider
  3. In the AI settings page, turn on Text to Speech
  4. Go to a post and find the Text to Speech panel in the sidebar
  5. Click on the Generate Audio button and ensure it works as expected

Changelog Entry

Added - Support for text to speech conversion

@dkotter dkotter added this to the 1.1.0 milestone Jul 21, 2026
@dkotter dkotter self-assigned this Jul 21, 2026
@dkotter
dkotter requested a review from a team July 21, 2026 18:40
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: superdav42 <superdav42@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@superdav42 superdav42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting one change before merge:

  • src/Models/OpenAiTextToSpeechConversionModel.php:213: an empty successful response is malformed provider output, but this branch throws Common\Exception\InvalidArgumentException, which represents bad caller input. The SDK reserves Providers\Http\Exception\ResponseException for unexpected or malformed provider responses, and the existing response parsers in this repository use ResponseException::fromMissingData(). The current exception type can make consumers misclassify the failure and skip their provider-error handling or retry path. Please throw a ResponseException here (for example, for a missing response body) and add a focused regression test that passes an empty 2xx body.

Verification: reviewed head 954aa2e; PHP syntax and PHPCS pass for all three changed files against locked wordpress/php-ai-client 1.3.1.

@dkotter

dkotter commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Requesting one change before merge:

  • src/Models/OpenAiTextToSpeechConversionModel.php:213: an empty successful response is malformed provider output, but this branch throws Common\Exception\InvalidArgumentException, which represents bad caller input. The SDK reserves Providers\Http\Exception\ResponseException for unexpected or malformed provider responses, and the existing response parsers in this repository use ResponseException::fromMissingData(). The current exception type can make consumers misclassify the failure and skip their provider-error handling or retry path. Please throw a ResponseException here (for example, for a missing response body)

Good idea, updated in e5ac5a3

and add a focused regression test that passes an empty 2xx body.

Right now this plugin has no tests which is why I didn't add any as part of this PR. It seems like a separate PR would be better to get test harness in place but let me know if you'd like all of this in this PR instead

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants