Error: Object of class Drupal\ai\OperationType\GenericType\AudioFile could not be converted to string in file_put_contents() (line 498 of FileSystem.php)
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3525028. --> Reported by: [paulsheldrake](https://www.drupal.org/user/1350686) Related to !611 !616 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>When using the Speech-to-Speech Explorer and clicking the "Generate audio response" button, the following error is triggered:</p> <pre>Error: Object of class Drupal\ai\OperationType\GenericType\AudioFile could not be converted to string in file_put_contents() (line 498 of /var/www/html/core/lib/Drupal/Core/File/FileSystem.php)<br>#0 /var/www/html/core/lib/Drupal/Core/File/FileSystem.php(498): file_put_contents()<br>#1 /var/www/html/modules/contrib/ai/modules/ai_api_explorer/src/Plugin/AiApiExplorer/SpeechToSpeechGenerator.php(155): Drupal\Core\File\FileSystem-&gt;saveData()<br>#2 /var/www/html/modules/contrib/ai/modules/ai_api_explorer/src/Form/AiApiExplorerForm.php(82): Drupal\ai_api_explorer\Plugin\AiApiExplorer\SpeechToSpeechGenerator-&gt;getResponse()</pre><p> This results in a fatal error and no audio response is generated. The issue is visible in both admin/reports/dblog and the browser console logs.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <ol> <li>Install the ElevenLabs module.</li> <li>Set up a free API key at <a href="https://elevenlabs.io/">https://elevenlabs.io/</a>.</li> <li>Configure the ElevenLabs provider at /admin/config/ai/settings.</li> <li>Navigate to the Speech-to-Speech Explorer(/admin/config/ai/explorers/speech_to_speech_generator)</li> <li>Click the "Generate audio response" button.</li> </ol> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>none</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>none</p> <h3 id="summary-ui-changes">User interface changes</h3> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3>
issue