Spaces:
Running
Running
Caching in docker implemented
Browse files- Dockerfile +21 -3
- app.py +9 -1
- tortoise/models/utils.py +7 -5
Dockerfile
CHANGED
@@ -8,14 +8,32 @@ WORKDIR /app
|
|
8 |
COPY . /app
|
9 |
|
10 |
# Install any needed packages specified in requirements.txt
|
11 |
-
RUN pip install --trusted-host pypi.python.org -r requirements.txt
|
12 |
-
pip uninstall transformers
|
13 |
pip install transformers==4.29.2
|
14 |
|
15 |
# Make port 80 available to the world outside this container
|
16 |
EXPOSE 80
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Run app.py when the container launches
|
21 |
CMD ["streamlit","run", "app.py"]
|
|
|
8 |
COPY . /app
|
9 |
|
10 |
# Install any needed packages specified in requirements.txt
|
11 |
+
RUN pip install --trusted-host pypi.python.org -r requirements.txt && \
|
12 |
+
pip uninstall transformers && \
|
13 |
pip install transformers==4.29.2
|
14 |
|
15 |
# Make port 80 available to the world outside this container
|
16 |
EXPOSE 80
|
17 |
|
18 |
+
# Set the TORTOISE_MODELS_DIR environment variable
|
19 |
+
ENV TORTOISE_MODELS_DIR tortoise/models/pretrained_models
|
20 |
+
|
21 |
+
# Create the directory for pretrained models
|
22 |
+
RUN mkdir -p $TORTOISE_MODELS_DIR
|
23 |
+
|
24 |
+
# Download all the models
|
25 |
+
RUN wget -O $TORTOISE_MODELS_DIR/autoregressive.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/autoregressive.pth && \
|
26 |
+
wget -O $TORTOISE_MODELS_DIR/classifier.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/classifier.pth && \
|
27 |
+
wget -O $TORTOISE_MODELS_DIR/clvp2.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/clvp2.pth && \
|
28 |
+
wget -O $TORTOISE_MODELS_DIR/cvvp.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/cvvp.pth && \
|
29 |
+
wget -O $TORTOISE_MODELS_DIR/diffusion_decoder.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/diffusion_decoder.pth && \
|
30 |
+
wget -O $TORTOISE_MODELS_DIR/vocoder.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/vocoder.pth && \
|
31 |
+
wget -O $TORTOISE_MODELS_DIR/rlg_auto.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/rlg_auto.pth && \
|
32 |
+
wget -O $TORTOISE_MODELS_DIR/rlg_diffuser.pth https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/rlg_diffuser.pth && \
|
33 |
+
wget -O $TORTOISE_MODELS_DIR/bigvgan_base_24khz_100band_g.pth https://drive.google.com/uc?id=1_cKskUDuvxQJUEBwdgjAxKuDTUW6kPdY && \
|
34 |
+
wget -O $TORTOISE_MODELS_DIR/bigvgan_24khz_100band_g.pth https://drive.google.com/uc?id=1wmP_mAs7d00KHVfVEl8B5Gb72Kzpcavp
|
35 |
+
|
36 |
+
RUN ls -la /app
|
37 |
|
38 |
# Run app.py when the container launches
|
39 |
CMD ["streamlit","run", "app.py"]
|
app.py
CHANGED
@@ -15,6 +15,9 @@ PRESETS = ["ultra_fast", "fast", "standard", "high_quality", "very_fast"]
|
|
15 |
UPLOAD_FOLDER = "./uploads"
|
16 |
OUTPUT_FOLDER = "./output"
|
17 |
|
|
|
|
|
|
|
18 |
# Create upload and output directories if they don't exist
|
19 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
20 |
os.makedirs(OUTPUT_FOLDER, exist_ok=True)
|
@@ -46,6 +49,7 @@ if st.sidebar.button("Create Voice") and voice_name.strip() != "":
|
|
46 |
wav_file.write(bytes_data)
|
47 |
|
48 |
st.sidebar.success(f"Voice '{voice_name}' created successfully!")
|
|
|
49 |
|
50 |
# Input text and settings
|
51 |
st.header("Text-to-Speech Generation")
|
@@ -68,7 +72,9 @@ if st.button("Generate Speech"):
|
|
68 |
st.info("Generating speech...")
|
69 |
|
70 |
# Load voice samples
|
71 |
-
voice_samples, conditioning_latents = load_voice(voice)
|
|
|
|
|
72 |
|
73 |
# Generate speech with Tortoise
|
74 |
gen = tts.tts_with_preset(
|
@@ -82,6 +88,8 @@ if st.button("Generate Speech"):
|
|
82 |
output_path = os.path.join(OUTPUT_FOLDER, "generated.wav")
|
83 |
torchaudio.save(output_path, gen.squeeze(0).cpu(), 24000)
|
84 |
|
|
|
|
|
85 |
# Log the path of the generated audio
|
86 |
st.write(f"Generated audio saved at: {output_path}")
|
87 |
|
|
|
15 |
UPLOAD_FOLDER = "./uploads"
|
16 |
OUTPUT_FOLDER = "./output"
|
17 |
|
18 |
+
voice_samples = None
|
19 |
+
conditioning_latents = None
|
20 |
+
|
21 |
# Create upload and output directories if they don't exist
|
22 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
23 |
os.makedirs(OUTPUT_FOLDER, exist_ok=True)
|
|
|
49 |
wav_file.write(bytes_data)
|
50 |
|
51 |
st.sidebar.success(f"Voice '{voice_name}' created successfully!")
|
52 |
+
voice_samples, conditioning_latents = load_voice(voice_name)
|
53 |
|
54 |
# Input text and settings
|
55 |
st.header("Text-to-Speech Generation")
|
|
|
72 |
st.info("Generating speech...")
|
73 |
|
74 |
# Load voice samples
|
75 |
+
# voice_samples, conditioning_latents = load_voice(voice)
|
76 |
+
|
77 |
+
print(voice_samples)
|
78 |
|
79 |
# Generate speech with Tortoise
|
80 |
gen = tts.tts_with_preset(
|
|
|
88 |
output_path = os.path.join(OUTPUT_FOLDER, "generated.wav")
|
89 |
torchaudio.save(output_path, gen.squeeze(0).cpu(), 24000)
|
90 |
|
91 |
+
print(output_path)
|
92 |
+
|
93 |
# Log the path of the generated audio
|
94 |
st.write(f"Generated audio saved at: {output_path}")
|
95 |
|
tortoise/models/utils.py
CHANGED
@@ -11,10 +11,12 @@ import progressbar
|
|
11 |
|
12 |
D_STEM = "https://drive.google.com/uc?id="
|
13 |
|
14 |
-
DEFAULT_MODELS_DIR = os.path.join(
|
15 |
-
|
16 |
-
)
|
17 |
-
MODELS_DIR = os.environ.get("TORTOISE_MODELS_DIR", DEFAULT_MODELS_DIR)
|
|
|
|
|
18 |
MODELS = {
|
19 |
"autoregressive.pth": "https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/autoregressive.pth",
|
20 |
"classifier.pth": "https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/classifier.pth",
|
@@ -76,5 +78,5 @@ def get_model_path(model_name, models_dir=MODELS_DIR):
|
|
76 |
return model_path
|
77 |
|
78 |
if __name__ == "__main__":
|
79 |
-
download_models() # to download all models
|
80 |
|
|
|
11 |
|
12 |
D_STEM = "https://drive.google.com/uc?id="
|
13 |
|
14 |
+
# DEFAULT_MODELS_DIR = os.path.join(
|
15 |
+
# os.path.expanduser("~"), ".cache", "tortoise", "models"
|
16 |
+
# )
|
17 |
+
# MODELS_DIR = os.environ.get("TORTOISE_MODELS_DIR", DEFAULT_MODELS_DIR)
|
18 |
+
|
19 |
+
MODELS_DIR = os.environ.get("TORTOISE_MODELS_DIR")
|
20 |
MODELS = {
|
21 |
"autoregressive.pth": "https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/autoregressive.pth",
|
22 |
"classifier.pth": "https://huggingface.co/jbetker/tortoise-tts-v2/resolve/main/.models/classifier.pth",
|
|
|
78 |
return model_path
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
+
# download_models() # to download all models
|
82 |
|