PHP code example of listen / ali-vms

1. Go to this page and download the library: Download listen/ali-vms 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/ */

    

listen / ali-vms example snippets




return [
    'uri'         => env('ALI_VMS_URI', 'http://nls-gateway.cn-shanghai.aliyuncs.com/stream/v1/asr'),  // Request Uri
    'appkey'      => env('ALI_VMS_APPKEY', ''),   // APP KEY                                      
    'host'        => env('ALI_VMS_HOST', 'nls-gateway.cn-shanghai.aliyuncs.com'),  // Host
    'timeout'     => 120,
    'log_file'    => storage_path('logs/alivms.log'), // Log File Path
    'log_channel'  => env('ALIVMS_LOG_CHANNEL', 'alivms'),
    'log_mode'     => env('ALIVMS_LOG_MODE', 'single')
];

# use tmp file
$file = $request->file('audio');
dd(AliVms::voiceDetection($file->getRealPath()));

# use file 
dd(AliVms::voiceDetection('path/to/file.pcm'));
sh
php artisan vendor:publish

\AliVms::pushExceptionCallback('dingtalk', function ($module, $message, $code, $otherParams) {
    // https://github.com/listen-rain/dingtalk
    sendByDingtalk($message . "\n\n Code: {$code}", "{$module}.error");
});