When using the provider service textToSpeech()
method, it saves the file in a random temp name. The method didn't use the second parameter $filename
. existed but not used.
Using the $filename
variable inside the getAsFileEntity()
method.
Use this code:
$prompt = "Test text";
$config = [
"stability" => 0,
"similarity_boost" => 0,
"style" => 0,
"use_speaker_boost" => 1,
];
$ai_provider = \Drupal::service('ai.provider')->createInstance('elevenlabs');
$ai_provider->setConfiguration($config);
$response = $ai_provider->textToSpeech($prompt, 'id_here', ["your_module_name"]);
$normalized = $response->getNormalized();
$file = $normalized[0]->getAsFileEntity("public://", "audio.mp3");
Closed: won't fix
1.0
Code