Spaces:
Paused
Paused
Upload 2 files
Browse files- Dockerfile +7 -2
- main.py +2 -1
Dockerfile
CHANGED
|
@@ -22,15 +22,20 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|
| 22 |
pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
# Create a non-root user and switch to it
|
| 25 |
-
# Hugging Face Spaces runs as user 1000
|
| 26 |
RUN useradd -m -u 1000 user
|
| 27 |
-
USER user
|
| 28 |
ENV HOME=/home/user \
|
| 29 |
PATH=/home/user/.local/bin:$PATH
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Copy the rest of the application code
|
| 32 |
COPY --chown=user . .
|
| 33 |
|
|
|
|
|
|
|
| 34 |
# Pre-download the model weights during build time
|
| 35 |
RUN python download_model.py
|
| 36 |
|
|
|
|
| 22 |
pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
# Create a non-root user and switch to it
|
|
|
|
| 25 |
RUN useradd -m -u 1000 user
|
|
|
|
| 26 |
ENV HOME=/home/user \
|
| 27 |
PATH=/home/user/.local/bin:$PATH
|
| 28 |
|
| 29 |
+
WORKDIR /app
|
| 30 |
+
|
| 31 |
+
# Create output directory and set permissions before switching user
|
| 32 |
+
RUN mkdir -p /app/outputs && chown user:user /app/outputs
|
| 33 |
+
|
| 34 |
# Copy the rest of the application code
|
| 35 |
COPY --chown=user . .
|
| 36 |
|
| 37 |
+
USER user
|
| 38 |
+
|
| 39 |
# Pre-download the model weights during build time
|
| 40 |
RUN python download_model.py
|
| 41 |
|
main.py
CHANGED
|
@@ -41,7 +41,8 @@ def cleanup_file(filepath: str):
|
|
| 41 |
|
| 42 |
def generate_audio(req: TTSRequest) -> str:
|
| 43 |
"""Generates audio and returns the filename."""
|
| 44 |
-
|
|
|
|
| 45 |
try:
|
| 46 |
audio_tensor = tts_model.generate(req.message, language_id=req.language)
|
| 47 |
ta.save(filename, audio_tensor, tts_model.sr)
|
|
|
|
| 41 |
|
| 42 |
def generate_audio(req: TTSRequest) -> str:
|
| 43 |
"""Generates audio and returns the filename."""
|
| 44 |
+
os.makedirs("outputs", exist_ok=True)
|
| 45 |
+
filename = os.path.join("outputs", f"{req.channelID}-{req.username}-{req.messageid}.wav")
|
| 46 |
try:
|
| 47 |
audio_tensor = tts_model.generate(req.message, language_id=req.language)
|
| 48 |
ta.save(filename, audio_tensor, tts_model.sr)
|