Upload 4 files
Browse files- Dockerfile +16 -6
- requirements.txt +1 -1
- tts-server.py +3 -0
Dockerfile
CHANGED
|
@@ -4,20 +4,30 @@ FROM python:3.9-slim
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Copy the current directory contents into the container at /app
|
| 8 |
-
COPY . /app
|
| 9 |
|
| 10 |
# Install any needed packages specified in requirements.txt
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# Make port
|
| 14 |
-
EXPOSE
|
| 15 |
|
| 16 |
# Define environment variable
|
| 17 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Run tts-server.py when the container launches
|
| 23 |
-
|
|
|
|
|
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Create a non-root user for Hugging Face Spaces
|
| 8 |
+
RUN useradd -m -u 1000 user
|
| 9 |
+
|
| 10 |
# Copy the current directory contents into the container at /app
|
| 11 |
+
COPY --chown=user . /app
|
| 12 |
|
| 13 |
# Install any needed packages specified in requirements.txt
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
+
# Make port 7860 available to the world outside this container
|
| 17 |
+
EXPOSE 7860
|
| 18 |
|
| 19 |
# Define environment variable
|
| 20 |
ENV PYTHONUNBUFFERED=1
|
| 21 |
+
ENV PASSWORD=sk-wei123
|
| 22 |
+
|
| 23 |
+
# Create cookie directory and set permissions
|
| 24 |
+
RUN mkdir -p cookie && chown -R user:user /app
|
| 25 |
|
| 26 |
+
# Switch to non-root user
|
| 27 |
+
USER user
|
| 28 |
+
ENV HOME=/home/user \
|
| 29 |
+
PATH=/home/user/.local/bin:$PATH
|
| 30 |
|
| 31 |
# Run tts-server.py when the container launches
|
| 32 |
+
# Note: We need to bind to 0.0.0.0 and port 7860 for HF Spaces
|
| 33 |
+
CMD ["uvicorn", "tts-server:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
aiohttp
|
| 4 |
-
websockets
|
| 5 |
pydantic
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn
|
| 3 |
aiohttp
|
| 4 |
+
websockets==10.4
|
| 5 |
pydantic
|
tts-server.py
CHANGED
|
@@ -271,6 +271,9 @@ class DoubaoTTS:
|
|
| 271 |
}
|
| 272 |
|
| 273 |
try:
|
|
|
|
|
|
|
|
|
|
| 274 |
async with websockets.connect(ws_url, extra_headers=headers) as ws:
|
| 275 |
# Send Text Event
|
| 276 |
msg = {
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
try:
|
| 274 |
+
# Try to use extra_headers, if it fails, it might be a version issue or specific environment quirk
|
| 275 |
+
# But standard websockets library uses extra_headers.
|
| 276 |
+
# Let's try to be safe and use the standard way.
|
| 277 |
async with websockets.connect(ws_url, extra_headers=headers) as ws:
|
| 278 |
# Send Text Event
|
| 279 |
msg = {
|