Issue #3575716: Support Azure AI Speech endpoints for text to speech

Closes #3575716.

Text to speech now also works with Azure AI Speech endpoints (https://<region>.tts.speech.microsoft.com/cognitiveservices/v1, or .../tts/cognitiveservices/v1 on a custom domain), as well as with Azure OpenAI .../audio/speech deployments.

For a Speech endpoint:

  • the text is sent as SSML, XML-escaped, in the voice's locale;
  • response_format maps to X-Microsoft-OutputFormat: mp3, opus, wav and pcm are supported, and aac and flac give a clear error;
  • the key is sent as Ocp-Apim-Subscription-Key, unless the model uses a bearer token or a custom header;
  • an OpenAI voice such as alloy gives an error that names an Azure voice to use instead.

The voice setting is now free text, so Azure voice names can be entered. Its description lists the OpenAI voices. Azure OpenAI requests are unchanged.

Testing

There are new unit tests, AzureSpeechTest and AudioClientTest, which use a mocked HTTP client. phpcs and phpstan pass locally.

Edited by Joshua Fernandes

Merge request reports

Loading
Loading