Generate with AI fails with real text-to-speech providers

Problem/Motivation

Generate with AI on the spoken disclaimer page fails with every real text-to-speech provider. Tests passed because they use a fake provider.

Steps to reproduce

  1. Install drupal/ai and drupal/elevenlabs, set ElevenLabs as the default text-to-speech provider.
  2. On Media > Spoken disclaimer, press Generate with AI.
  3. Error: "The AI module has no textToSpeech()".

Proposed resolution

  • ai.provider returns a ProviderProxy, which forwards calls through __call(). method_exists() is false on it, so check with is_callable().
  • Pass the provider's default configuration. ElevenLabs needs a voice and has no default: use the first voice it offers.

Choosing the voice per language is a separate feature.

Remaining tasks

  • Fix and a kernel test with a provider behind a __call() proxy
  • Check with ElevenLabs on the test site

Part of #80 (closed).

AI Compliance

🤖 Generated with the help of an LLM, reviewed and approved by me before posting.

Edited by Giorgio Alfredo Pagano