CrazyMonkey0 commited on
Commit
65952f6
·
1 Parent(s): df63d34

test(tts): checking whether the tts model is working correctly

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -12
  2. app/routes/nlp.py +18 -20
Dockerfile CHANGED
@@ -1,26 +1,21 @@
1
- # Zamiast FROM python:3.12, użyj swojego obrazu bazowego
2
- FROM crazymonkey00/llama-base:latest
3
 
4
- # Ustaw katalog roboczy
5
  WORKDIR /app
6
 
7
- # Skopiuj requirements.txt (bez llama-cpp-python - już jest w obrazie!)
8
  COPY ./requirements.txt /app/requirements.txt
9
 
10
- # Zainstaluj tylko dodatkowe zależności z Twojego projektu
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Skopiuj cały kod aplikacji
14
  COPY . /app
15
 
16
- # Expose port dla Hugging Face Spaces
17
  EXPOSE 7860
18
 
19
- # set environment variables
20
- ENV CUDA_VISIBLE_DEVICES=""
21
- ENV TF_CPP_MIN_LOG_LEVEL=2
22
- ENV TF_ENABLE_ONEDNN_OPTS=0
23
-
24
  # Run FastAPI with Gunicorn - increased timeout for model loading
25
  CMD ["gunicorn", "app.main:app", \
26
  "-k", "uvicorn.workers.UvicornWorker", \
 
1
+ # Instead of FROM python:3.12, use a slim base image
2
+ FROM python:3.12-slim
3
 
4
+ # Set the working directory
5
  WORKDIR /app
6
 
7
+ # Copy requirements.txt (llama-cpp-python is already included in the base image)
8
  COPY ./requirements.txt /app/requirements.txt
9
 
10
+ # Install only project-specific dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy the entire application source code
14
  COPY . /app
15
 
16
+ # Expose port for Hugging Face Spaces
17
  EXPOSE 7860
18
 
 
 
 
 
 
19
  # Run FastAPI with Gunicorn - increased timeout for model loading
20
  CMD ["gunicorn", "app.main:app", \
21
  "-k", "uvicorn.workers.UvicornWorker", \
app/routes/nlp.py CHANGED
@@ -66,23 +66,21 @@ async def chat(request: Request, chat_request: ChatRequest):
66
  skip_special_tokens=True
67
  ).strip()
68
 
69
- return {"response": response_text}
70
-
71
- # # Generate audio using TTS
72
- # audio_bytes = save_audio(request, response_text)
73
-
74
- # # Create a multipart response
75
- # boundary = uuid.uuid4().hex
76
- # body = (
77
- # f"--{boundary}\r\n"
78
- # f"Content-Disposition: form-data; name=\"text\"\r\n\r\n"
79
- # f"{response_text}\r\n"
80
- # f"--{boundary}\r\n"
81
- # f"Content-Disposition: form-data; name=\"audio\"; filename=\"speech.wav\"\r\n"
82
- # f"Content-Type: audio/wav\r\n\r\n"
83
- # ).encode() + audio_bytes + f"\r\n--{boundary}--\r\n".encode()
84
-
85
- # return Response(
86
- # content=body,
87
- # media_type=f"multipart/form-data; boundary={boundary}"
88
- # )
 
66
  skip_special_tokens=True
67
  ).strip()
68
 
69
+ # Generate audio using TTS
70
+ audio_bytes = save_audio(request, response_text)
71
+
72
+ # Create a multipart response
73
+ boundary = uuid.uuid4().hex
74
+ body = (
75
+ f"--{boundary}\r\n"
76
+ f"Content-Disposition: form-data; name=\"text\"\r\n\r\n"
77
+ f"{response_text}\r\n"
78
+ f"--{boundary}\r\n"
79
+ f"Content-Disposition: form-data; name=\"audio\"; filename=\"speech.wav\"\r\n"
80
+ f"Content-Type: audio/wav\r\n\r\n"
81
+ ).encode() + audio_bytes + f"\r\n--{boundary}--\r\n".encode()
82
+
83
+ return Response(
84
+ content=body,
85
+ media_type=f"multipart/form-data; boundary={boundary}"
86
+ )