audio-sentiment / DEPLOYMENT_WINDOWS.md
alec228's picture
Deploy: Analyse de sentiment audio v1.0
56d1009

A newer version of the Gradio SDK is available: 5.44.1

Upgrade

🪟 Guide de Déploiement Windows - Hugging Face Spaces

📋 Prérequis Windows

  1. Git pour Windows : git-scm.com
  2. Python 3.8+ : python.org
  3. PowerShell (inclus avec Windows 10/11)
  4. Compte Hugging Face : huggingface.co

🚀 Options de déploiement

Option 1 : PowerShell (Recommandé)

# Ouvrir PowerShell en tant qu'administrateur
.\deploy.ps1 <votre-username> sentiment-audio-analyzer

Option 2 : Batch (CMD)

# Ouvrir l'invite de commandes
deploy.bat <votre-username> sentiment-audio-analyzer

Option 3 : Manuel (Git Bash)

# Installer Git Bash depuis git-scm.com
./deploy.sh <votre-username> sentiment-audio-analyzer

🔧 Configuration PowerShell

Si vous avez des problèmes avec PowerShell, exécutez :

# Autoriser l'exécution de scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# Vérifier la politique
Get-ExecutionPolicy

📁 Structure des fichiers Windows

sentiment_hf_/
├── app_with_api.py          # Application principale
├── requirements_hf.txt       # Dépendances
├── config.yaml              # Configuration HF Spaces
├── deploy.ps1               # Script PowerShell
├── deploy.bat               # Script Batch
├── deploy.sh                # Script Bash (pour Git Bash)
├── test_deployment.py       # Tests
├── test_api.py              # Tests API
├── src/                     # Code source
│   ├── __init__.py
│   ├── transcription.py
│   ├── sentiment.py
│   ├── multimodal.py
│   ├── inference.py
│   ├── app.py              # Original
│   └── api.py              # Original
└── Documentation/
    ├── README_HF.md
    ├── API_DOCUMENTATION.md
    └── DEPLOYMENT_SUMMARY.md

🎯 Étapes de déploiement Windows

1. Préparation

# Ouvrir PowerShell dans le dossier du projet
cd "C:\Users\Benoit\Desktop\DIT\PROJET_DL\sentiment_hf_"

# Vérifier que Python est installé
python --version

# Vérifier que Git est installé
git --version

2. Test local

# Tester le projet
python test_deployment.py

# Tester l'API (si l'application est lancée)
python test_api.py

3. Créer le Space sur Hugging Face

  1. Allez sur huggingface.co/spaces
  2. Cliquez "Create new Space"
  3. Remplissez :
    • Owner : Votre nom d'utilisateur
    • Space name : sentiment-audio-analyzer
    • SDK : Gradio
    • Hardware : CPU (gratuit)

4. Déploiement automatisé

# Avec PowerShell (recommandé)
.\deploy.ps1 <votre-username> sentiment-audio-analyzer

# Ou avec Batch
deploy.bat <votre-username> sentiment-audio-analyzer

5. Déploiement manuel (alternative)

# Initialiser Git si nécessaire
git init

# Ajouter le remote HF
git remote add hf https://huggingface.co/spaces/<username>/sentiment-audio-analyzer

# Ajouter et commiter
git add .
git commit -m "Initial deployment"

# Pousser
git push hf main

🚨 Dépannage Windows

Problème : "ExecutionPolicy"

# Solution
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Problème : "python not found"

# Vérifier l'installation Python
python --version
# ou
py --version

# Ajouter Python au PATH si nécessaire

Problème : "git not found"

# Installer Git depuis git-scm.com
# Redémarrer PowerShell après installation

Problème : "Permission denied"

# Exécuter PowerShell en tant qu'administrateur
# Ou utiliser Git Bash

Problème : "SSL Certificate"

# Configurer Git pour ignorer les certificats SSL
git config --global http.sslVerify false

🔍 Vérification du déploiement

1. Vérifier le Space

  • Allez sur votre URL : https://huggingface.co/spaces/<username>/sentiment-audio-analyzer
  • Attendez que le build se termine (5-10 minutes)

2. Tester l'interface Gradio

  • Enregistrez un audio ou uploadez un fichier
  • Vérifiez que l'analyse fonctionne

3. Tester l'API

# Test de l'API
python test_api.py

4. Vérifier les logs

  • Dans votre Space HF, allez dans l'onglet "Logs"
  • Surveillez les erreurs éventuelles

📊 Monitoring Windows

Logs PowerShell

# Rediriger les logs
.\deploy.ps1 <username> <space> | Tee-Object -FilePath "deploy.log"

Logs Git

# Voir l'historique des commits
git log --oneline

# Voir les remotes
git remote -v

🌟 Optimisations Windows

1. Variables d'environnement

# Ajouter Python au PATH
$env:PATH += ";C:\Python39\Scripts\;C:\Python39\"

# Configurer Git
git config --global user.name "Votre Nom"
git config --global user.email "votre.email@example.com"

2. Alias PowerShell

# Ajouter à votre profil PowerShell
function Deploy-HF { param($user, $space) .\deploy.ps1 $user $space }
function Test-HF { python test_deployment.py }

3. Script de mise à jour

# Créer update.ps1
git add .
git commit -m "Update: $args[0]"
git push hf main

📞 Support Windows

Ressources utiles

Commandes utiles

# Vérifier les versions
python --version
git --version
node --version  # Si vous utilisez Node.js

# Nettoyer le cache
git gc
git prune

# Vérifier l'espace disque
Get-PSDrive C

🎉 Félicitations !

Votre projet est maintenant déployé sur Hugging Face Spaces depuis Windows !

URL finale : https://huggingface.co/spaces/<votre-username>/sentiment-audio-analyzer

API : https://huggingface.co/spaces/<votre-username>/sentiment-audio-analyzer/api/


Guide optimisé pour Windows 10/11 avec PowerShell