Files
einundzwanzig-portal/app/Traits/HasTextToSpeech.php
HolgerHatGarKeineNode c6ee8f9854 TTS
2023-04-25 23:36:12 +02:00

41 lines
1.1 KiB
PHP

<?php
namespace App\Traits;
use App\CodeIsSpeech;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Route;
trait HasTextToSpeech
{
use CodeIsSpeech;
public function mountHasTextToSpeech()
{
$id = str(Route::currentRouteName())
->replace('.', ' ')
->camel()
->toString();
$text = $this->$id();
File::put(storage_path('app/public/tts/'.$id.'.txt'), $text);
if (
in_array($id, [
'authLn',
'profileLnbits',
'meetupWorld',
'bitcoinEventTableBitcoinEvent',
'libraryTableLibraryItems',
'schoolTableCourse',
])
&& File::exists(storage_path('app/public/tts/'.$id.'.wav'))
) {
dispatch(new \App\Jobs\CodeIsSpeech($id, false))->delay(now()->addSecond());
} elseif (in_array($id, ['welcome']) && auth()->check()) {
} else {
dispatch(new \App\Jobs\CodeIsSpeech($id))->delay(now()->addSecond());
}
}
}