encode) { $response = Http::get('http://host.docker.internal:5002/api/tts', [ 'text' => File::get(storage_path('app/public/tts/'.$this->id.'.txt')), 'speaker_id' => null, 'style_wav' => null, 'language_id' => null, ]); File::put(storage_path('app/public/tts/'.$this->id.'.wav'), $response->body()); } elseif (!File::exists(storage_path('app/public/tts/'.$this->id.'.wav'))) { $response = Http::get('http://host.docker.internal:5002/api/tts', [ 'text' => File::get(storage_path('app/public/tts/'.$this->id.'.txt')), 'speaker_id' => null, 'style_wav' => null, 'language_id' => null, ]); File::put(storage_path('app/public/tts/'.$this->id.'.wav'), $response->body()); } event(new AudioTextToSpeechChangedEvent(url('storage/tts/'.$this->id.'.wav'))); } }