Audio
Connect providers specialized in processing Audio to Text and vice-versa
Wrap into an Agent
namespace App\Neuron;
use NeuronAI\Agent\Agent;
use NeuronAI\Chat\Messages\UserMessage;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\OpenAI\Audio\OpenAITextToSpeech;
class MyAgent extends Agent
{
protected function provider(): AIProviderInterface
{
return new OpenAITextToSpeech(
key: 'OPENAI_API_KEY',
model: 'gpt-4o-mini-tts',
voice: 'alloy',
);
}
}
// Run the agent
$message = MyAgent::make()
->chat(new UserMessage("Hi!"))
->getMessage();
// Retrieve the audio part of the message (it's in base64 format)
$audioBase64 = $message->getAudio();
// Save the audio file
file_put_contents(__DIR__.'/assets/speech.mp3', base64_decode($audioBase64));Direct use
OpenAI Audio
Text-To-Speech
Speech-To-Text
ElevenLabs
Text-To-Speech
Speach-To-Text
Last updated