Spaces:
Paused
Paused
Commit
·
d13204f
1
Parent(s):
f65a442
Updates Dockerfile
Browse files- Dockerfile +4 -3
- app.py +3 -3
Dockerfile
CHANGED
|
@@ -19,11 +19,12 @@ RUN pip install --no-cache-dir Cython
|
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
-
# Create writable
|
| 23 |
-
RUN mkdir -p /data/hf_cache /data/transformers_cache /data/nltk_data /data/audio static/audio && \
|
| 24 |
-
chmod -R 777 /data static
|
| 25 |
chmod -R 777 /root/.cache
|
| 26 |
|
|
|
|
| 27 |
# Set environment variables
|
| 28 |
ENV HF_HOME=/data/hf_cache
|
| 29 |
ENV TRANSFORMERS_CACHE=/data/transformers_cache
|
|
|
|
| 19 |
COPY requirements.txt .
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
+
# Create writable directories
|
| 23 |
+
RUN mkdir -p /data/hf_cache /data/transformers_cache /data/nltk_data /data/audio /static/audio && \
|
| 24 |
+
chmod -R 777 /data /static && \
|
| 25 |
chmod -R 777 /root/.cache
|
| 26 |
|
| 27 |
+
|
| 28 |
# Set environment variables
|
| 29 |
ENV HF_HOME=/data/hf_cache
|
| 30 |
ENV TRANSFORMERS_CACHE=/data/transformers_cache
|
app.py
CHANGED
|
@@ -12,12 +12,13 @@ from parler_tts import ParlerTTSForConditionalGeneration
|
|
| 12 |
|
| 13 |
# Flask setup
|
| 14 |
dir_path = os.path.dirname(os.path.realpath(__file__))
|
| 15 |
-
app = Flask(__name__, static_folder="static")
|
| 16 |
CORS(app)
|
| 17 |
|
| 18 |
# Paths
|
| 19 |
AUDIO_FOLDER = '/static/audio'
|
| 20 |
os.makedirs(AUDIO_FOLDER, exist_ok=True)
|
|
|
|
| 21 |
|
| 22 |
class ChatBot:
|
| 23 |
def __init__(self):
|
|
@@ -127,7 +128,6 @@ class ChatBot:
|
|
| 127 |
|
| 128 |
chatbot = ChatBot()
|
| 129 |
|
| 130 |
-
app = Flask(__name__, static_folder="static", static_url_path="")
|
| 131 |
@app.route("/")
|
| 132 |
def serve_index():
|
| 133 |
return send_from_directory(app.static_folder, "index.html")
|
|
@@ -140,7 +140,7 @@ def chat_endpoint():
|
|
| 140 |
if not user_text:
|
| 141 |
return jsonify({"error": "Empty message"}), 400
|
| 142 |
resp_text, wav_name = asyncio.run(chatbot.chat(user_text, gender))
|
| 143 |
-
url = f"
|
| 144 |
return jsonify({"response": resp_text, "audiofile": url})
|
| 145 |
|
| 146 |
@app.route('/static/audio/<path:filename>')
|
|
|
|
| 12 |
|
| 13 |
# Flask setup
|
| 14 |
dir_path = os.path.dirname(os.path.realpath(__file__))
|
| 15 |
+
app = Flask(__name__, static_folder="static", static_url_path="")
|
| 16 |
CORS(app)
|
| 17 |
|
| 18 |
# Paths
|
| 19 |
AUDIO_FOLDER = '/static/audio'
|
| 20 |
os.makedirs(AUDIO_FOLDER, exist_ok=True)
|
| 21 |
+
os.chmod(AUDIO_FOLDER, 0o777)
|
| 22 |
|
| 23 |
class ChatBot:
|
| 24 |
def __init__(self):
|
|
|
|
| 128 |
|
| 129 |
chatbot = ChatBot()
|
| 130 |
|
|
|
|
| 131 |
@app.route("/")
|
| 132 |
def serve_index():
|
| 133 |
return send_from_directory(app.static_folder, "index.html")
|
|
|
|
| 140 |
if not user_text:
|
| 141 |
return jsonify({"error": "Empty message"}), 400
|
| 142 |
resp_text, wav_name = asyncio.run(chatbot.chat(user_text, gender))
|
| 143 |
+
url = f"audio/{wav_name}"
|
| 144 |
return jsonify({"response": resp_text, "audiofile": url})
|
| 145 |
|
| 146 |
@app.route('/static/audio/<path:filename>')
|