aungkomyat commited on
Commit
44742c4
·
verified ·
1 Parent(s): b4842b7

Create setup_repo.py

Browse files
Files changed (1) hide show
  1. setup_repo.py +95 -0
setup_repo.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import sys
4
+ import subprocess
5
+ import shutil
6
+ from pathlib import Path
7
+
8
+ # Configuration
9
+ REPO_URL = "https://github.com/hpbyte/myanmar-tts.git"
10
+ REPO_DIR = "myanmar-tts"
11
+ MODEL_DIR = "trained_model"
12
+
13
+ def setup_repository():
14
+ """Clone and set up the Myanmar TTS repository."""
15
+ print(f"Setting up Myanmar TTS repository...")
16
+
17
+ # Clone the repository if it doesn't exist
18
+ if not os.path.exists(REPO_DIR):
19
+ print(f"Cloning repository from {REPO_URL}...")
20
+ subprocess.run(["git", "clone", REPO_URL], check=True)
21
+ print("Repository cloned successfully!")
22
+ else:
23
+ print(f"Repository already exists at {REPO_DIR}")
24
+
25
+ # Create the model directory if it doesn't exist
26
+ if not os.path.exists(MODEL_DIR):
27
+ os.makedirs(MODEL_DIR)
28
+ print(f"Created model directory at {MODEL_DIR}")
29
+ else:
30
+ print(f"Model directory already exists at {MODEL_DIR}")
31
+
32
+ # Create placeholder files with instructions if they don't exist
33
+ checkpoint_path = os.path.join(MODEL_DIR, "checkpoint_latest.pth.tar")
34
+ config_path = os.path.join(MODEL_DIR, "hparams.yml")
35
+
36
+ if not os.path.exists(checkpoint_path):
37
+ with open(checkpoint_path, 'w') as f:
38
+ f.write("This is a placeholder file. Replace with the actual model checkpoint.")
39
+ print(f"Created placeholder file at {checkpoint_path}")
40
+
41
+ if not os.path.exists(config_path):
42
+ with open(config_path, 'w') as f:
43
+ f.write("# This is a placeholder file. Replace with the actual hparams.yml file.")
44
+ print(f"Created placeholder file at {config_path}")
45
+
46
+ # Make sure the repository packages are installed
47
+ try:
48
+ # Create a minimal setup.py in the repository if it doesn't exist
49
+ setup_path = os.path.join(REPO_DIR, "setup.py")
50
+ if not os.path.exists(setup_path):
51
+ with open(setup_path, 'w') as f:
52
+ f.write("""
53
+ from setuptools import setup, find_packages
54
+
55
+ setup(
56
+ name="myanmar_tts",
57
+ version="0.1.0",
58
+ packages=find_packages(),
59
+ install_requires=[
60
+ "inflect",
61
+ "unidecode",
62
+ "torch",
63
+ "numpy",
64
+ "scipy",
65
+ ],
66
+ )
67
+ """)
68
+ print("Created setup.py file in repository")
69
+
70
+ # Install the package in development mode
71
+ print("Installing Myanmar TTS package...")
72
+ subprocess.run([sys.executable, "-m", "pip", "install", "-e", REPO_DIR], check=True)
73
+ print("Myanmar TTS package installed successfully!")
74
+
75
+ # Create __init__.py files to make imports work
76
+ for subdir in ["text", "utils"]:
77
+ init_path = os.path.join(REPO_DIR, subdir, "__init__.py")
78
+ if not os.path.exists(init_path):
79
+ os.makedirs(os.path.dirname(init_path), exist_ok=True)
80
+ with open(init_path, 'w') as f:
81
+ f.write("# Auto-generated __init__.py file")
82
+ print(f"Created {init_path}")
83
+
84
+ except Exception as e:
85
+ print(f"Error during package installation: {str(e)}")
86
+ print("Continuing with setup...")
87
+
88
+ print("Repository setup complete!")
89
+ print("\nIMPORTANT: You need to upload the following files to the 'trained_model' directory:")
90
+ print("1. checkpoint_latest.pth.tar - The model checkpoint file")
91
+ print("2. hparams.yml - The hyperparameters configuration file")
92
+ print("\nThese files can be obtained from the original repository or by training the model.")
93
+
94
+ if __name__ == "__main__":
95
+ setup_repository()