Spaces:
Sleeping
Sleeping
Update apps/gradio_app/setup_scripts.py
Browse files- apps/gradio_app/setup_scripts.py +60 -60
apps/gradio_app/setup_scripts.py
CHANGED
|
@@ -1,61 +1,61 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
import sys
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
-
def run_script(script_path, args=None):
|
| 6 |
-
"""
|
| 7 |
-
Run a Python script using subprocess with optional arguments and handle errors.
|
| 8 |
-
Returns True if successful, False otherwise.
|
| 9 |
-
"""
|
| 10 |
-
try:
|
| 11 |
-
command = [sys.executable, script_path]
|
| 12 |
-
if args:
|
| 13 |
-
command.extend(args)
|
| 14 |
-
result = subprocess.run(
|
| 15 |
-
command,
|
| 16 |
-
check=True,
|
| 17 |
-
text=True,
|
| 18 |
-
capture_output=True
|
| 19 |
-
)
|
| 20 |
-
print(f"Successfully executed {script_path}")
|
| 21 |
-
print(result.stdout)
|
| 22 |
-
return True
|
| 23 |
-
except subprocess.CalledProcessError as e:
|
| 24 |
-
print(f"Error executing {script_path}:")
|
| 25 |
-
print(e.stderr)
|
| 26 |
-
return False
|
| 27 |
-
except FileNotFoundError:
|
| 28 |
-
print(f"Script not found: {script_path}")
|
| 29 |
-
return False
|
| 30 |
-
|
| 31 |
-
def main():
|
| 32 |
-
"""
|
| 33 |
-
Main function to execute setup_third_party.py and download_ckpts.py in sequence.
|
| 34 |
-
"""
|
| 35 |
-
scripts_dir = "scripts"
|
| 36 |
-
scripts = [
|
| 37 |
-
{
|
| 38 |
-
"path": os.path.join(scripts_dir, "setup_third_party.py"),
|
| 39 |
-
"args": None
|
| 40 |
-
},
|
| 41 |
-
{
|
| 42 |
-
"path": os.path.join(scripts_dir, "download_ckpts.py"),
|
| 43 |
-
"args": [
|
| 44 |
-
"--repo_id", "danhtran2mind/Vi-F5-TTS",
|
| 45 |
-
"--local_dir", "./ckpts",
|
| 46 |
-
"--pruning_model"
|
| 47 |
-
]
|
| 48 |
-
}
|
| 49 |
-
]
|
| 50 |
-
|
| 51 |
-
for script in scripts:
|
| 52 |
-
script_path = script["path"]
|
| 53 |
-
args = script["args"]
|
| 54 |
-
print(f"Start running {script_path} {' '.join(args) if args else ''}\n")
|
| 55 |
-
if not run_script(script_path, args):
|
| 56 |
-
print(f"Stopping execution due to error in {script_path}")
|
| 57 |
-
sys.exit(1)
|
| 58 |
-
print(f"Completed {script_path}\n")
|
| 59 |
-
|
| 60 |
-
if __name__ == "__main__":
|
| 61 |
main()
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
def run_script(script_path, args=None):
|
| 6 |
+
"""
|
| 7 |
+
Run a Python script using subprocess with optional arguments and handle errors.
|
| 8 |
+
Returns True if successful, False otherwise.
|
| 9 |
+
"""
|
| 10 |
+
try:
|
| 11 |
+
command = [sys.executable, script_path]
|
| 12 |
+
if args:
|
| 13 |
+
command.extend(args)
|
| 14 |
+
result = subprocess.run(
|
| 15 |
+
command,
|
| 16 |
+
check=True,
|
| 17 |
+
text=True,
|
| 18 |
+
capture_output=True
|
| 19 |
+
)
|
| 20 |
+
print(f"Successfully executed {script_path}")
|
| 21 |
+
print(result.stdout)
|
| 22 |
+
return True
|
| 23 |
+
except subprocess.CalledProcessError as e:
|
| 24 |
+
print(f"Error executing {script_path}:")
|
| 25 |
+
print(e.stderr)
|
| 26 |
+
return False
|
| 27 |
+
except FileNotFoundError:
|
| 28 |
+
print(f"Script not found: {script_path}")
|
| 29 |
+
return False
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
"""
|
| 33 |
+
Main function to execute setup_third_party.py and download_ckpts.py in sequence.
|
| 34 |
+
"""
|
| 35 |
+
scripts_dir = "scripts"
|
| 36 |
+
scripts = [
|
| 37 |
+
{
|
| 38 |
+
"path": os.path.join(scripts_dir, "setup_third_party.py"),
|
| 39 |
+
"args": None
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"path": os.path.join(scripts_dir, "download_ckpts.py"),
|
| 43 |
+
"args": [
|
| 44 |
+
"--repo_id", "danhtran2mind/Vi-F5-TTS",
|
| 45 |
+
"--local_dir", "./ckpts",
|
| 46 |
+
"--pruning_model"
|
| 47 |
+
]
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
print("run#################33")
|
| 51 |
+
for script in scripts:
|
| 52 |
+
script_path = script["path"]
|
| 53 |
+
args = script["args"]
|
| 54 |
+
print(f"Start running {script_path} {' '.join(args) if args else ''}\n")
|
| 55 |
+
if not run_script(script_path, args):
|
| 56 |
+
print(f"Stopping execution due to error in {script_path}")
|
| 57 |
+
sys.exit(1)
|
| 58 |
+
print(f"Completed {script_path}\n")
|
| 59 |
+
|
| 60 |
+
if __name__ == "__main__":
|
| 61 |
main()
|