Issue while running FastAPI TTS(Text To Speech) Docker Image on Serverless
We have made a TTS model that converts text input into an audio file. To serve this model, we created a REST API using the FastAPI framework with multiple endpoints, each performing specific tasks based on the text input. After building the API, we created a Dockerfile, pushed the image to Docker Hub, and attempted to run it on a serverless platform. However, while the container works perfectly on a local setup, it fails to run on the serverless environment.
Could you assist with how to successfully run the RestAPI container on a serverless platform, and once the container is running, how to access the FastAPI endpoints to send text input and get audio responses?
Docker File:
FROM ubuntu:22.04# Install system dependencies and Python 3.10RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ python3-venv \ python3-pip \ python3-dev \ curl \ bash \ build-essential \ libsndfile1 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/*RUN apt-get update && apt-get install -y ffmpeg# Set up virtual environmentENV VIRTUAL_ENV=/opt/openvoiceRUN python3 -m venv $VIRTUAL_ENVENV PATH="$VIRTUAL_ENV/bin:$PATH"# Upgrade pipRUN pip install --no-cache-dir --upgrade pip# RUN apt-get update && apt-get install -y python3-dev build-essential# Install torch and other dependenciesRUN pip install --no-cache-dir torch setuptools>=40.8.0 langid fastapi soundfile librosa inflect unidecode eng_to_ipa pypinyin jiebaRUN pip install cn2an pydub faster_whisper whisper_timestampedRUN pip install --upgrade setuptools# Expose the ports used by the applicationEXPOSE 8000# Copy application codeCOPY . .# Create a startup scriptRUN echo '#!/bin/bash\n\source /opt/openvoice/bin/activate\n\python tts_2.py' > /start.sh && chmod +x /start.sh# Run the applicationCMD ["/bin/bash", "/start.sh"]
FROM ubuntu:22.04# Install system dependencies and Python 3.10RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ python3-venv \ python3-pip \ python3-dev \ curl \ bash \ build-essential \ libsndfile1 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/*RUN apt-get update && apt-get install -y ffmpeg# Set up virtual environmentENV VIRTUAL_ENV=/opt/openvoiceRUN python3 -m venv $VIRTUAL_ENVENV PATH="$VIRTUAL_ENV/bin:$PATH"# Upgrade pipRUN pip install --no-cache-dir --upgrade pip# RUN apt-get update && apt-get install -y python3-dev build-essential# Install torch and other dependenciesRUN pip install --no-cache-dir torch setuptools>=40.8.0 langid fastapi soundfile librosa inflect unidecode eng_to_ipa pypinyin jiebaRUN pip install cn2an pydub faster_whisper whisper_timestampedRUN pip install --upgrade setuptools# Expose the ports used by the applicationEXPOSE 8000# Copy application codeCOPY . .# Create a startup scriptRUN echo '#!/bin/bash\n\source /opt/openvoice/bin/activate\n\python tts_2.py' > /start.sh && chmod +x /start.sh# Run the applicationCMD ["/bin/bash", "/start.sh"]
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
R
Runpod
We're a community of enthusiasts, engineers, and enterprises, all sharing insights on AI, Machine Learning and GPUs!