PHP code example of dij-digital / deepgram-laravel

1. Go to this page and download the library: Download dij-digital/deepgram-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dij-digital / deepgram-laravel example snippets


use 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,
]);

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'),

];

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');
});
bash
php artisan vendor:publish --tag="deepgram-laravel-config"