This package provides a seamless integration with Deepgram's AI voice services. Built following Laravel conventions.
- Transcribe local audio files
- Configurable transcription options (model, language, smart formatting)
Requires PHP 8.3 or higher and Laravel 12+
⚡️ Install the package using Composer:
composer require dij-digital/deepgram-laravel Publish the config file:
php artisan vendor:publish --tag="deepgram-laravel-config"Add your Deepgram API credentials to your .env file:
DEEPGRAM_API_KEY=your-api-key-here
DEEPGRAM_BASE_URL=https://api.deepgram.com/v1
DEEPGRAM_DEFAULT_MODEL=nova-2
DEEPGRAM_DEFAULT_LANGUAGE=en-USuse DIJ\Deepgram\Facades\Deepgram;
// Basic transcription with config defaults
$result = Deepgram::listen()->transcribeFile('/path/to/audio.wav', 'audio/wav');
// With custom options per call
$result = Deepgram::listen()->transcribeFile('/path/to/audio.wav', 'audio/wav', [
'model' => 'nova-3',
'language' => 'en',
'smart_format' => true,
'punctuate' => true,
'diarize' => true,
]);The published config file (config/deepgram-laravel.php) contains the following options:
return [
'api_key' => env('DEEPGRAM_API_KEY'),
'base_url' => env('DEEPGRAM_BASE_URL', 'https://api.deepgram.com/v1'),
'default_model' => env('DEEPGRAM_DEFAULT_MODEL', 'nova-2'),
'default_language' => env('DEEPGRAM_DEFAULT_LANGUAGE', 'nl'),
];When testing your application, you can use Deepgram::fake() to prevent real HTTP calls to the Deepgram API:
use DIJ\Deepgram\Facades\Deepgram;
it('can process audio files', function () {
// Prevent real API calls
Deepgram::fake();
// Your application code - no real HTTP calls will be made
$result = Deepgram::listen()->transcribeFile('/path/to/audio.wav');
// Returns fake transcription data for testing
expect($result)->toBeArray()->toHaveKey('results');
});The fake will return realistic fake transcription data so your tests can run without hitting the actual Deepgram API.
You can also use Laravel's standard facade mocking methods, like Deepgram::shouldReceive()->once()->andReturn() for more precise control if needed.
Deepgram Laravel was created by DIJ Digital under the MIT license.