dij-digital/deepgram-laravel
Composer 安装命令:
composer require dij-digital/deepgram-laravel
包简介
A Laravel package for integrating Deepgram’s AI voice services
README 文档
README
This package provides a seamless integration with Deepgram's AI voice services. Built following Laravel conventions.
This package supports the following features:
Speech-to-Text
- 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
Configuration
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-US
How to use this package
Basic File Transcription
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, ]);
Configuration Options
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'), ];
Testing
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.
统计信息
- 总下载量: 938
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-16