承接 realhood/assemblyai-realtime 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

realhood/assemblyai-realtime

Composer 安装命令:

composer require realhood/assemblyai-realtime

包简介

PHP package for AssemblyAI real-time streaming with Lemur support

README 文档

README

A comprehensive PHP package for real-time transcription and Lemur integration with AssemblyAI. This package provides a robust implementation for real-time audio transcription and AI-powered analysis using AssemblyAI's WebSocket API and Lemur capabilities.

Features

  • 🎙️ Real-time audio transcription
  • 🤖 Lemur AI integration for advanced analysis
  • 📝 Support for multiple Lemur tasks (summarization, Q&A, action items)
  • 🔄 WebSocket-based streaming with automatic reconnection
  • ⚡ Efficient audio processing and chunking
  • 🛠️ Comprehensive error handling
  • 🧪 Full test coverage

Requirements

  • PHP 7.4 or higher
  • Composer
  • AssemblyAI API key

Installation

composer require realhood/assemblyai-realtime

Quick Start

use AssemblyAIRealtime\Client\AssemblyAIClient;
use AssemblyAIRealtime\Config\Configuration;

// Initialize client with Lemur
$config = new Configuration([
    'lemur' => [
        'enabled' => true,
        'task' => 'summarize',
        'prompt' => 'Provide a brief summary'
    ]
]);

$client = new AssemblyAIClient('your-api-key', $config);

// Handle transcription results
$messageHandler = function($result) {
    switch ($result['type']) {
        case 'partial':
            echo "Partial: {$result['text']}\n";
            break;
        case 'final':
            echo "Final: {$result['text']}\n";
            break;
        case 'lemur':
            echo "Lemur: {$result['response']}\n";
            break;
    }
};

// Start transcription
$client->startRealTimeTranscription($messageHandler);

// Send audio data
$client->sendAudioChunk($audioData);

// Stop when done
$client->stop();

Advanced Usage

Audio Processing

use AssemblyAIRealtime\Utils\AudioUtils;

// Validate audio format
if (AudioUtils::validateAudioFormat($audioPath)) {
    // Get audio duration
    $duration = AudioUtils::getAudioDuration($audioPath);
    
    // Convert and process audio
    $chunks = AudioUtils::convertAudioToFormat($audioPath);
    foreach ($chunks as $chunk) {
        $client->sendAudioChunk($chunk);
        usleep(20000); // 20ms delay
    }
}

Lemur Integration

use AssemblyAIRealtime\Utils\LemurUtils;

// Create Lemur configuration
$lemurConfig = LemurUtils::createLemurConfig(
    'summarize',
    'Provide a detailed summary'
);

// Available Lemur tasks
$tasks = [
    'summarize',
    'question_answer',
    'action_items',
    'key_points'
];

Error Handling

try {
    $client->startRealTimeTranscription($handler);
} catch (AssemblyAIException $e) {
    echo "AssemblyAI Error: " . $e->getMessage();
} catch (TranscriptionException $e) {
    echo "Transcription Error: " . $e->getMessage();
} catch (LemurException $e) {
    echo "Lemur Error: " . $e->getMessage();
}

Testing

Run the test suite:

./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.

Credits

Created and maintained by Reza Aleyasin.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-15