Skip to content
Snippets Groups Projects

Resolved generate audio response for speech to speech explorer.

1 file
+ 2
1
Compare changes
  • Side-by-side
  • Inline
@@ -143,7 +143,8 @@ final class SpeechToSpeechGenerator extends AiApiExplorerPluginBase {
$destination = 'temporary://ai-explorers/';
$this->fileSystem->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY);
$random = (string) rand();
$file_url = $this->fileSystem->saveData($audio_normalized, $destination . '/' . md5($random) . '.mp3');
$binary_data = $audio_normalized[0]->getBinary();
$file_url = $this->fileSystem->saveData($binary_data, $destination . '/' . md5($random) . '.mp3');
$file_name = basename($file_url);
$url = Url::fromRoute('system.temporary', [], ['query' => ['file' => 'ai-explorers/' . $file_name]]);
$form['right']['response']['#context']['ai_response']['response'] = [
Loading