PHP code example of bugadoz / woolball-library

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

    

bugadoz / woolball-library example snippets






$apiKey = 'SUA_API_KEY';
$woolball = new WoolballLibrary\WoolballAPI($apiKey);

$audioData = $woolball->textToSpeech('Olá mundo', 'pt');
file_put_contents('output.mp3', $audioData);

$transcription = $woolball->speechToText('audio.wav');
echo $transcription;

$generatedText = $woolball->generateText('Qual é a capital da França?','HuggingFaceTB/SmolLM2-360M-Instruct');
echo $generatedText;


$translatedText = $woolball->translateText('Olá, mundo!', 'por_Latn', 'eng_Latn');
echo $translatedText;

$classification = $woolball->classifyText('Qual cidade não está na América do Sul?', ['geografia', 'viagem', 'história']);
echo $classification;

$emotions = $woolball->detectFacialEmotions('img.png');
echo $emotions;

$description = $woolball->analyzeImage('img.png', 'Descreva o conteúdo da imagem');
echo $description;

$labels = $woolball->classifyImages(['img1.png', 'img2.png']);
print_r($labels);

$summary = $woolball->summarizeText('Texto longo aqui...');
echo $summary;

$imageBase64 = $woolball->charToImage('A');
file_put_contents('character.png', base64_decode($imageBase64));

$sentiment = $woolball->analyzeSentiment('Estou muito feliz hoje!');
echo $sentiment;

try {
    $result = $woolball->textToSpeech('Olá mundo', 'pt');
} catch (Exception $e) {
    echo 'Erro: ' . $e->getMessage();
}