PHP code example of invis1ble / media-intelligence
1. Go to this page and download the library: Download invis1ble/media-intelligence 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/ */
invis1ble / media-intelligence example snippets
// ./public/index.php
declare(strict_types=1);
ion;
// Set here your own OpenAI API Key.
// Visit https://platform.openai.com/account/api-keys for more details.
$openAiApiKey = '';
$audioTargetDirectoryPath = sys_get_temp_dir();
$application = new Application(
apiKey: $openAiApiKey,
audioTargetDirectory: new SplFileInfo($audioTargetDirectoryPath),
);
$facts = $application->run('https://www.youtube.com/watch?v=JdMw9lQTNnc');
/** @var iterable<string> $facts List of the extracted facts */
foreach ($facts as $fact) {
echo "- $fact\n";
}
// ...
use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
// ...
$logger = new Logger(
name: 'video_to_facts_logger',
handlers: [
// write all staff to the file
new StreamHandler(__DIR__ . '/../logs/video_to_facts.log', Level::Debug),
// write info and higher to console
new StreamHandler(STDOUT, Level::Info),
],
);
$application = new Application(
apiKey: $openAiApiKey,
audioTargetDirectory: new SplFileInfo($audioTargetDirectoryPath),
debug: true,
);
$application->setLogger($logger);
$facts = $application->run('https://www.youtube.com/watch?v=JdMw9lQTNnc');
/** @var iterable<string> $facts List of the extracted facts */