Spaces:
Sleeping
Sleeping
| """ | |
| 📊 Résumé complet du projet MMS ASR/TTS API | |
| Ce projet fournit une API Flask pour: | |
| - ASR (Automatic Speech Recognition): Audio → Texte avec support 100+ langues | |
| - TTS (Text-to-Speech): Texte → Audio pour 8 langues | |
| Utilise les modèles Meta MMS: | |
| - facebook/mms-1b-all (ASR, 964M params) | |
| - facebook/mms-tts-{lang} (TTS, 8 langues) | |
| """ | |
| import json | |
| PROJECT_STRUCTURE = { | |
| "docs": { | |
| "README.md": "Documentation générale du projet", | |
| "ARCHITECTURE.md": "Architecture technique détaillée", | |
| "DEPLOYMENT.md": "Guide de déploiement sur Hugging Face Spaces", | |
| }, | |
| "source_code": { | |
| "app.py": "API Flask v1 - Version stable", | |
| "app_v2.py": "API Flask v2 - Version optimisée (RECOMMANDÉE) ⭐", | |
| "client.py": "Client Python pour tester l'API", | |
| "examples.py": "Exemples d'utilisation des endpoints", | |
| }, | |
| "testing": { | |
| "test_api.py": "Tests unitaires avec pytest", | |
| "setup_project.py": "Script de vérification et setup du projet", | |
| }, | |
| "deployment": { | |
| "requirements.txt": "Dépendances production", | |
| "requirements-dev.txt": "Dépendances développement (tests, linting)", | |
| "Dockerfile": "Conteneur Docker pour déploiement", | |
| "docker-compose.yml": "Orchestration Docker (GPU support)", | |
| ".gitignore": "Fichiers à ignorer par Git", | |
| }, | |
| } | |
| QUICK_START = """ | |
| 🚀 DÉMARRAGE RAPIDE | |
| ═══════════════════════════════════════════════════════════════ | |
| 1️⃣ Installation: | |
| cd /home/ronaldo/Bureau/test | |
| pip install -r requirements.txt | |
| 2️⃣ Lancer l'API: | |
| python app_v2.py | |
| # API disponible sur http://localhost:7860 | |
| 3️⃣ Tester dans un autre terminal: | |
| python examples.py | |
| 4️⃣ Tester avec curl: | |
| # ASR - Convertir audio en texte | |
| curl -X POST -F "audio=@audio.wav" \\ | |
| http://localhost:7860/asr | |
| # TTS - Convertir texte en audio | |
| curl -X POST -H "Content-Type: application/json" \\ | |
| -d '{"text":"Hello","language":"eng"}' \\ | |
| http://localhost:7860/tts --output hello.wav | |
| 5️⃣ Déployer sur Hugging Face: | |
| Voir DEPLOYMENT.md pour les instructions | |
| """ | |
| FEATURES = { | |
| "ASR": { | |
| "model": "facebook/mms-1b-all", | |
| "languages": "100+ langues (ISO 639-3)", | |
| "input": "Audio (WAV, MP3, etc.)", | |
| "output": "Texte transcrit", | |
| "endpoint": "POST /asr", | |
| }, | |
| "TTS": { | |
| "model": "facebook/mms-tts-* (VITS)", | |
| "languages": 8, | |
| "supported": ["beh", "bba", "ddn", "ewe", "gej", "tbz", "yor", "eng"], | |
| "input": "Texte (max 1000 chars)", | |
| "output": "Audio WAV (22050 Hz)", | |
| "endpoint": "POST /tts", | |
| }, | |
| "General": { | |
| "framework": "Flask", | |
| "gpu_support": "CUDA auto-detect", | |
| "cache": "In-memory model cache (thread-safe)", | |
| "cors": "Enabled", | |
| "max_audio": "30 secondes", | |
| "max_text": "1000 caractères", | |
| }, | |
| } | |
| ENDPOINTS = { | |
| "GET /": "Documentation de l'API", | |
| "GET /health": "État du service + device info", | |
| "GET /supported-languages": "Langues supportées", | |
| "GET /models-info": "Informations détaillées sur les modèles", | |
| "POST /asr": "Audio → Texte (ASR)", | |
| "POST /tts": "Texte → Audio (TTS)", | |
| } | |
| def print_section(title, content=None): | |
| """Affiche une section formatée""" | |
| print(f"\n{'═' * 70}") | |
| print(f" {title}") | |
| print(f"{'═' * 70}") | |
| if content: | |
| print(content) | |
| def print_project_structure(): | |
| """Affiche la structure du projet""" | |
| for category, files in PROJECT_STRUCTURE.items(): | |
| print(f"\n📂 {category.upper()}:") | |
| for filename, description in files.items(): | |
| print(f" 📄 {filename:25} → {description}") | |
| def print_features(): | |
| """Affiche les features""" | |
| print(f"\n🎯 FEATURES:") | |
| for feature, details in FEATURES.items(): | |
| print(f"\n {feature}:") | |
| for key, value in details.items(): | |
| if isinstance(value, list): | |
| value = ", ".join(value) | |
| print(f" • {key}: {value}") | |
| def print_endpoints(): | |
| """Affiche les endpoints""" | |
| print(f"\n📡 API ENDPOINTS:") | |
| for endpoint, description in ENDPOINTS.items(): | |
| print(f" {endpoint:25} → {description}") | |
| def main(): | |
| """Fonction principale""" | |
| print(""" | |
| ╔════════════════════════════════════════════════════════════════╗ | |
| ║ 🎙️ Meta MMS ASR/TTS API 🔊 ║ | |
| ║ Reconnaissance vocale + Synthèse vocale ║ | |
| ║ Multilingue & GPU-ready ║ | |
| ╚════════════════════════════════════════════════════════════════╝ | |
| """) | |
| print_section("📋 STRUCTURE DU PROJET") | |
| print_project_structure() | |
| print_section("🎯 FEATURES") | |
| print_features() | |
| print_section("📡 API ENDPOINTS") | |
| print_endpoints() | |
| print_section("🚀 DÉMARRAGE RAPIDE") | |
| print(QUICK_START) | |
| print_section("💡 INFORMATIONS SUPPLÉMENTAIRES") | |
| print(""" | |
| ✅ Recommandations: | |
| • Utiliser app_v2.py (v1 is deprecated) | |
| • Installer requirements.txt pour prod | |
| • Voir examples.py pour voir comment utiliser l'API | |
| • Pour dev: pip install -r requirements-dev.txt | |
| 📚 Documentation complète: | |
| • README.md - Documentation générale | |
| • ARCHITECTURE.md - Architecture technique | |
| • DEPLOYMENT.md - Déploiement sur HF Spaces | |
| 🧪 Tests: | |
| • pytest test_api.py -v | |
| 📊 Déploiement: | |
| • Local: python app_v2.py | |
| • Docker: docker build -t mms . && docker run -p 7860:7860 mms | |
| • HF Spaces: Voir DEPLOYMENT.md | |
| 🌐 URLs importantes: | |
| • facebook/mms-1b-all: https://huggingface.co/facebook/mms-1b-all | |
| • facebook/mms-tts: https://huggingface.co/facebook/mms-tts | |
| • Meta MMS Paper: https://arxiv.org/abs/2305.13516 | |
| """) | |
| print_section("🎓 PROCHAINES ÉTAPES") | |
| print(""" | |
| 1. ✅ Installer les dépendances | |
| 2. ✅ Lancer l'API localement | |
| 3. ✅ Tester les endpoints | |
| 4. ✅ Déployer sur Hugging Face Spaces | |
| 5. ✅ Ajouter des features (streaming, batch, etc.) | |
| Bon codage! 🚀 | |
| """) | |
| if __name__ == "__main__": | |
| main() | |