Socold commited on
Commit
8872f6b
·
verified ·
1 Parent(s): 60be90d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -23
app.py CHANGED
@@ -3,17 +3,17 @@ import subprocess
3
  import sys
4
 
5
  # Cloner votre repository
6
- if not os.path.exists("VibeVoice-X"):
7
- subprocess.run(["git", "clone", "https://github.com/Socold/VibeVoice-X.git"])
8
 
9
- sys.path.insert(0, "VibeVoice-X")
10
 
11
  # Installer les dépendances
12
  subprocess.run([sys.executable, "-m", "pip", "install", "-q",
13
  "torch", "transformers>=4.40.0", "accelerate", "gradio>=4.0.0",
14
  "soundfile", "librosa", "scipy", "numpy", "ffmpeg-python"])
15
 
16
- subprocess.run([sys.executable, "-m", "pip", "install", "-e", "VibeVoice-X"])
17
 
18
  import torch
19
  import gradio as gr
@@ -21,34 +21,58 @@ import gradio as gr
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())
 
 
3
  import sys
4
 
5
  # Cloner votre repository
6
+ if not os.path.exists("VV_Clone_1"):
7
+ subprocess.run(["git", "clone", "https://github.com/Socold/VV_Clone_1.git"])
8
 
9
+ sys.path.insert(0, "VV_Clone_1")
10
 
11
  # Installer les dépendances
12
  subprocess.run([sys.executable, "-m", "pip", "install", "-q",
13
  "torch", "transformers>=4.40.0", "accelerate", "gradio>=4.0.0",
14
  "soundfile", "librosa", "scipy", "numpy", "ffmpeg-python"])
15
 
16
+ subprocess.run([sys.executable, "-m", "pip", "install", "-e", "VV_Clone_1"])
17
 
18
  import torch
19
  import gradio as gr
 
21
  # Configuration
22
  MODEL_PATH = "aoi-ot/VibeVoice-7B"
23
 
24
+ # DEBUG : Vérifier les secrets
25
+ print("=== VÉRIFICATION AUTHENTIFICATION ===")
26
  USERNAME = os.environ.get("AUTH_USERNAME")
27
  PASSWORD = os.environ.get("AUTH_PASSWORD")
28
+ print(f"AUTH_USERNAME présent: {USERNAME is not None}")
29
+ print(f"AUTH_PASSWORD présent: {PASSWORD is not None}")
30
+ if USERNAME:
31
+ print(f"Utilisateur: {USERNAME}")
32
+ print("====================================")
33
 
34
  print(f"Modèle: {MODEL_PATH}")
35
  print(f"GPU: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU'}")
36
 
37
+ os.chdir("VV_Clone_1")
 
38
 
39
+ # Lire le fichier original
40
+ with open("demo/gradio_demo.py", "r") as f:
41
+ original_content = f.read()
42
 
43
+ # Si auth configurée, modifier le fichier
44
  if USERNAME and PASSWORD:
45
+ print("Modification du fichier pour ajouter l'authentification...")
 
 
46
 
47
+ # Chercher différents patterns possibles
48
+ if "demo.launch(share=args.share)" in original_content:
49
+ new_content = original_content.replace(
50
+ "demo.launch(share=args.share)",
51
+ f'demo.launch(share=args.share, auth=("{USERNAME}", "{PASSWORD}"))'
52
  )
53
+ elif "demo.launch()" in original_content:
54
+ new_content = original_content.replace(
55
+ "demo.launch()",
56
+ f'demo.launch(auth=("{USERNAME}", "{PASSWORD}"))'
57
+ )
58
+ else:
59
+ # Pattern plus général
60
+ import re
61
+ new_content = re.sub(
62
+ r'demo\.launch\((.*?)\)',
63
+ f'demo.launch(\\1, auth=("{USERNAME}", "{PASSWORD}"))',
64
+ original_content
65
+ )
66
+
67
+ # Écrire le fichier modifié
68
+ with open("demo/gradio_demo.py", "w") as f:
69
+ f.write(new_content)
70
+
71
+ print("✅ Authentification ajoutée")
72
+ else:
73
+ print("⚠️ ATTENTION: Pas de secrets configurés - Space PUBLIC!")
74
 
75
+ # Lancer
76
+ sys.argv = ["gradio_demo.py", "--model_path", MODEL_PATH, "--share"]
77
+ from demo.gradio_demo import main
78
+ main()