Update app.py
Browse files12345679 unmodified lines171819202122232425262728293031323334353637383940414243444546474849505152535455import osimport subprocessimport sysimport gradio as gr# Cloner votre repositoryif not os.path.exists("VibeVoice-X"):9 unmodified linessubprocess.run([sys.executable, "-m", "pip", "install", "-e", "VibeVoice-X"])import torch# ConfigurationMODEL_PATH = "aoi-ot/VibeVoice-7B"# FORCER l'authentificationUSERNAME = os.environ.get("AUTH_USERNAME", None)PASSWORD = os.environ.get("AUTH_PASSWORD", None)if not USERNAME or not PASSWORD:print("ERREUR: Secrets AUTH_USERNAME et AUTH_PASSWORD non configurés!")print("L'interface sera publique sans authentification.")else:print(f"Authentification activée pour: {USERNAME}")# Importer après les installationsfrom demo.gradio_demo import VibeVoiceDemo# Créer l'instancedemo = VibeVoiceDemo(model_path=MODEL_PATH)# Lancer avec authentification DIRECTEMENTif USERNAME and PASSWORD:demo.launch_demo().launch(auth=(USERNAME, PASSWORD),auth_message="Entrez vos identifiants VibeVoice",server_name="0.0.0.0",share=False)else:# Si pas de secrets, lancer sans auth mais avec avertissementgr.Interface(fn=lambda x: "ERREUR: Configurez AUTH_USERNAME et AUTH_PASSWORD dans Settings → Secrets!",inputs="text",outputs="text",title="⚠️ Authentification non configurée").launch()1234569 unmodified lines161718192021222324252627282930313233343536373839404142434445464748495051525354import osimport subprocessimport sys# Cloner votre repositoryif not os.path.exists("VibeVoice-X"):9 unmodified linessubprocess.run([sys.executable, "-m", "pip", "install", "-e", "VibeVoice-X"])import torchimport gradio as gr# ConfigurationMODEL_PATH = "aoi-ot/VibeVoice-7B"# Récupérer les secretsUSERNAME = os.environ.get("AUTH_USERNAME")PASSWORD = os.environ.get("AUTH_PASSWORD")print(f"Modèle: {MODEL_PATH}")print(f"GPU: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU'}")# Debug authentificationprint(f"Auth configurée: {bool(USERNAME and PASSWORD)}")# Changer de dossier et lanceros.chdir("VibeVoice-X")# Méthode 1 : Utiliser directement le scriptif USERNAME and PASSWORD:# Modifier le fichier pour ajouter l'authwith open("demo/gradio_demo.py", "r") as f:content = f.read()# Trouver et remplacer la ligne launchif "demo.launch(" in content:content = content.replace('demo.launch(',f'demo.launch(auth=("{USERNAME}", "{PASSWORD}"), ')with open("demo/gradio_demo.py", "w") as f:f.write(content)# Lancer le script principalsys.argv = ["gradio_demo.py", "--model_path", MODEL_PATH]exec(open("demo/gradio_demo.py").read())
app.py+27-28