PHP code example of aistemsplitter / aistemsplitter-php

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

    

aistemsplitter / aistemsplitter-php example snippets




IStemSplitter\Client;

$client = new Client(getenv('AISTEMSPLITTER_API_KEY'));

$credits = $client->getCredits();
echo $credits['balance'] . ' ' . $credits['unit'] . PHP_EOL;

$split = $client->createSplit([
    'input' => [
        'type' => 'direct_url',
        'url' => 'https://example.com/song.mp3',
    ],
    'stemModel' => '6s',
], idempotencyKey: 'retry-001');

$result = $client->waitForSplit($split['id'], timeoutMs: 10 * 60 * 1000, intervalMs: 2000);
print_r($result['stems'] ?? []);

$upload = $client->uploadAudio(
    filename: 'song.mp3',
    contentType: 'audio/mpeg',
    contents: file_get_contents(__DIR__ . '/song.mp3'),
);

$split = $client->createSplit([
    'input' => $upload['input'],
    'stemModel' => '4s',
]);
sh
AISTEMSPLITTER_API_KEY=ast_live_xxx php examples/smoke.php
sh
composer validate --strict
composer test
php -l src/Client.php
php -l src/AIStemSplitterException.php