dij-digital/deepgram-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固