audio-sentiment / API_SUMMARY.md
alec228's picture
Initial commit
efca0f4

A newer version of the Gradio SDK is available: 5.44.1

Upgrade

🔌 API REST - Résumé

API opérationnelle !

Votre API REST est maintenant entièrement fonctionnelle et intégrée dans le déploiement Hugging Face Spaces.

🚀 Endpoints disponibles

Endpoint Méthode Description
/api/ GET Informations générales
/api/health GET Vérification état
/api/predict POST Analyse audio
/api/predict_text POST Analyse textuelle
/api/docs GET Documentation Swagger

📖 Utilisation rapide

Analyse audio

curl -X POST "https://huggingface.co/spaces/<username>/sentiment-audio-analyzer/api/predict" \
     -F "file=@audio.wav"

Analyse textuelle

curl -X POST "https://huggingface.co/spaces/<username>/sentiment-audio-analyzer/api/predict_text" \
     -H "Content-Type: application/json" \
     -d '{"text": "je suis content"}'

🎯 Fonctionnalités

  • Transcription audio avec Wav2Vec2
  • Analyse sentiment avec BERT
  • Gestion d'erreurs robuste
  • Validation fichiers (WAV, FLAC, MP3, max 50MB)
  • Documentation Swagger interactive
  • Support CORS pour intégration web
  • Fallback vers analyse textuelle si multimodal échoue

🔧 Intégration

Python

import requests

# Analyse audio
response = requests.post(API_URL + "/api/predict", files={"file": open("audio.wav", "rb")})
result = response.json()
print(f"Sentiment: {result['sentiment']}")

JavaScript

// Analyse audio
const formData = new FormData();
formData.append('file', audioFile);

fetch(API_URL + '/api/predict', {
  method: 'POST',
  body: formData
})
.then(response => response.json())
.then(data => console.log(data.sentiment));

📊 Réponse type

{
  "transcription": "je suis très content de ce produit",
  "sentiment": {
    "négatif": 0.05,
    "neutre": 0.10,
    "positif": 0.85
  },
  "filename": "audio.wav",
  "file_size": 123456
}

🧪 Tests

Testez votre API avec :

python test_api.py

📚 Documentation complète

Consultez API_DOCUMENTATION.md pour la documentation détaillée.


🎉 Votre API est prête pour la production !