mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
TTS
This commit is contained in:
40
app/Console/Commands/TTS/CodeIsSpeech.php
Normal file
40
app/Console/Commands/TTS/CodeIsSpeech.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\TTS;
|
||||
|
||||
use App\Events\AudioTextToSpeechChangedEvent;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CodeIsSpeech extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'tts:encode {--text=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$response = Http::get('http://host.docker.internal:5002/api/tts', [
|
||||
'text' => File::get(storage_path('app/public/tts/'.$this->option('text').'.txt')),
|
||||
'speaker_id' => null,
|
||||
'style_wav' => null,
|
||||
'language_id' => null,
|
||||
]);
|
||||
|
||||
File::put(storage_path('app/public/tts/'.$this->option('text').'.wav'), $response->body());
|
||||
|
||||
event(new AudioTextToSpeechChangedEvent(url('storage/tts/'.$this->option('text').'.wav')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user