Socold commited on
Commit
60be90d
·
verified ·
1 Parent(s): 42a849b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -28
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import os
2
  import subprocess
3
  import sys
4
- import gradio as gr
5
 
6
  # Cloner votre repository
7
  if not os.path.exists("VibeVoice-X"):
@@ -17,39 +16,39 @@ subprocess.run([sys.executable, "-m", "pip", "install", "-q",
17
  subprocess.run([sys.executable, "-m", "pip", "install", "-e", "VibeVoice-X"])
18
 
19
  import torch
 
20
 
21
  # Configuration
22
  MODEL_PATH = "aoi-ot/VibeVoice-7B"
23
 
24
- # FORCER l'authentification
25
- USERNAME = os.environ.get("AUTH_USERNAME", None)
26
- PASSWORD = os.environ.get("AUTH_PASSWORD", None)
27
 
28
- if not USERNAME or not PASSWORD:
29
- print("ERREUR: Secrets AUTH_USERNAME et AUTH_PASSWORD non configurés!")
30
- print("L'interface sera publique sans authentification.")
31
- else:
32
- print(f"Authentification activée pour: {USERNAME}")
33
 
34
- # Importer après les installations
35
- from demo.gradio_demo import VibeVoiceDemo
36
 
37
- # Créer l'instance
38
- demo = VibeVoiceDemo(model_path=MODEL_PATH)
39
 
40
- # Lancer avec authentification DIRECTEMENT
41
  if USERNAME and PASSWORD:
42
- demo.launch_demo().launch(
43
- auth=(USERNAME, PASSWORD),
44
- auth_message="Entrez vos identifiants VibeVoice",
45
- server_name="0.0.0.0",
46
- share=False
47
- )
48
- else:
49
- # Si pas de secrets, lancer sans auth mais avec avertissement
50
- gr.Interface(
51
- fn=lambda x: "ERREUR: Configurez AUTH_USERNAME et AUTH_PASSWORD dans Settings → Secrets!",
52
- inputs="text",
53
- outputs="text",
54
- title="⚠️ Authentification non configurée"
55
- ).launch()
 
 
 
1
  import os
2
  import subprocess
3
  import sys
 
4
 
5
  # Cloner votre repository
6
  if not os.path.exists("VibeVoice-X"):
 
16
  subprocess.run([sys.executable, "-m", "pip", "install", "-e", "VibeVoice-X"])
17
 
18
  import torch
19
+ import gradio as gr
20
 
21
  # Configuration
22
  MODEL_PATH = "aoi-ot/VibeVoice-7B"
23
 
24
+ # Récupérer les secrets
25
+ USERNAME = os.environ.get("AUTH_USERNAME")
26
+ PASSWORD = os.environ.get("AUTH_PASSWORD")
27
 
28
+ print(f"Modèle: {MODEL_PATH}")
29
+ print(f"GPU: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU'}")
 
 
 
30
 
31
+ # Debug authentification
32
+ print(f"Auth configurée: {bool(USERNAME and PASSWORD)}")
33
 
34
+ # Changer de dossier et lancer
35
+ os.chdir("VibeVoice-X")
36
 
37
+ # Méthode 1 : Utiliser directement le script
38
  if USERNAME and PASSWORD:
39
+ # Modifier le fichier pour ajouter l'auth
40
+ with open("demo/gradio_demo.py", "r") as f:
41
+ content = f.read()
42
+
43
+ # Trouver et remplacer la ligne launch
44
+ if "demo.launch(" in content:
45
+ content = content.replace(
46
+ 'demo.launch(',
47
+ f'demo.launch(auth=("{USERNAME}", "{PASSWORD}"), '
48
+ )
49
+ with open("demo/gradio_demo.py", "w") as f:
50
+ f.write(content)
51
+
52
+ # Lancer le script principal
53
+ sys.argv = ["gradio_demo.py", "--model_path", MODEL_PATH]
54
+ exec(open("demo/gradio_demo.py").read())