-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d6bd49
commit a06c120
Showing
5 changed files
with
93 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
env/ | ||
__pycache__/ | ||
# Ignore data and checkpoints directories | ||
backend/data/ | ||
backend/checkpoints/ | ||
|
||
*.env | ||
*.env* | ||
env.* | ||
# Ignore Git and version control | ||
.git | ||
.gitignore | ||
|
||
# Ignore other unnecessary files | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
__pycache__ | ||
*.swp | ||
.DS_Store | ||
|
||
# Ignore specific files or other directories as needed | ||
# e.g., local environment files, IDE-specific files, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
DB_USERNAME=postgres | ||
DB_PASSWORD=postgres | ||
DB_HOST=localhost | ||
DB_NAME=crawler | ||
|
||
STORAGE_OPTION=local | ||
GCS_BUCKET_NAME=bucket-path | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,80 @@ | ||
# FastAPI CloudRun Starter | ||
# [titolo] | ||
|
||
This repository serves as a starter template for setting up a FastAPI backend using Google CloudRun. It's designed to streamline the process of deploying a FastAPI application using modern infrastructure as code principles. | ||
This repository aims to establish a foundation for deploying a backend using Docker, which utilizes OpenVoice and FastAPI. The main functionality is to recognize the voice timbre from a YouTube video and recreate the same video with a text-to-speech model in the same timbre after translating the subtitles. This is just a basic setup. | ||
|
||
## Steps: | ||
|
||
1. Submit a YouTube link via the endpoint `/api/v1/download/`. | ||
2. The final processed video is saved in `backend/data/final_videos`. | ||
|
||
## Features | ||
|
||
- Terraform-based infrastructure setup. | ||
- Integration with GitHub Actions for continuous integration. | ||
- Automatic trigger setup for Cloud Build. | ||
- Secure storage of secrets using Secret Manager. | ||
- Deployment via GitHub Actions and Cloud Build on a Cloud Run. | ||
|
||
Currently ho provato the deployment is on a Cloud Run (thus, only CPU is used for inference). | ||
|
||
For a starting template on setting up Cloud Run with Terraform, refer to this link: | ||
[FastAPI-CloudRun-Starter](https://github.com/mazzasaverio/fastapi-cloudrun-starter) | ||
|
||
## Next Steps | ||
|
||
- Test better models. | ||
- Test serverless GPU. | ||
- Add a frontend. | ||
- Improve translation synchronization. | ||
|
||
## Local Installation Instructions | ||
|
||
We recommend the following for local installation: | ||
|
||
``` | ||
conda install mamba -n base -c conda-forge | ||
mamba create -n youtube-auto-dub python=3.9 -y | ||
mamba install -n youtube-auto-dub pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia -y | ||
conda activate youtube-auto-dub | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Download the checkpoint from [here](https://myshell-public-repo-hosting.s3.amazonaws.com/checkpoints_1226.zip) and extract it to the `checkpoints` folder. Insert the checkpoint found in `checkpoints_1226` into the `backend` folder. | ||
|
||
## Getting Started | ||
conda install mamba -n base -c conda-forge | ||
|
||
### Prerequisites | ||
mamba create -n youtube-auto-dub python=3.9 -y | ||
|
||
1. **Google Cloud Platform Account**: Ensure you have an active GCP account. [Sign up here](https://cloud.google.com/) if needed. | ||
2. **Project Setup**: Create a new GCP project and note down the project ID. | ||
3. **Service Account**: Create a service account with 'Owner' permissions in your GCP project and generate a JSON key file. | ||
4. **Connecting Cloud Build to Your GitHub Account**: Create a personal access token in GitHub with `repo` and `read:user` permissions. For organization apps, include `read:org` permission. [Guide here](https://cloud.google.com/build/docs/automating-builds/github/connect-repo-github?generation=2nd-gen#terraform_1). | ||
mamba install -n youtube-auto-dub pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia -y | ||
|
||
### Terraform Configuration | ||
conda activate youtube-auto-dub | ||
|
||
- **Rename File**: Rename `terraform.tfvars.example` to `terraform.tfvars`. | ||
- **Insert Credentials**: Fill in your credentials in the `terraform.tfvars` file. | ||
pip install pytube moviepy fastapi uvicorn loguru youtube-dl youtube-transcript-api librosa | ||
|
||
### Docker Configuration | ||
pip install googletrans==4.0.0-rc1 | ||
|
||
The `Dockerfile` is configured to use the NVIDIA CUDA base image with FastAPI dependencies. The application is exposed on port 8000 and can be customized as needed. | ||
sudo apt -y install -qq aria2 unzip | ||
|
||
### FastAPI Application | ||
sudo aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://myshell-public-repo-hosting.s3.amazonaws.com/checkpoints_1226.zip -d /code -o checkpoints_1226.zip | ||
|
||
The `main.py` script is the entry point for the FastAPI application. It includes basic routes and can be extended for additional functionalit | ||
sudo unzip /code/checkpoints_1226.zip | ||
|
||
## Usage | ||
## Reference and Inspiration | ||
|
||
To deploy the infrastructure and application: | ||
| Repository | Stars | Forks | Last Updated | About | | ||
| :--------------------------------------------------: | :---: | :---: | :----------: | :-------------------------------: | | ||
| [OpenVoice](https://github.com/myshell-ai/OpenVoice) | 13972 | 1213 | 2024-02-09 | Instant voice cloning by MyShell. | | ||
|
||
1. Initialize Terraform: | ||
```bash | ||
terraform init | ||
``` | ||
2. Apply Terraform configuration: | ||
```bash | ||
terraform apply | ||
``` | ||
3. To build and run the Docker container locally, use: | ||
```bash | ||
docker-compose up --build | ||
``` | ||
<!-- START_SECTION:under-review --> | ||
## Repositories Under Review | ||
|
||
## Contributing | ||
| Repository | Stars | Forks | Last Updated | About | | ||
|:-:|:-:|:-:|:-:|:-:| | ||
<!-- END_SECTION:under-review --> | ||
<!-- START_SECTION:reference-inspiration --> | ||
## Reference and Inspiration | ||
|
||
Contributions to enhance this starter template are welcome. Please follow standard GitHub contribution guidelines. | ||
| Repository | Stars | Forks | Last Updated | About | | ||
|:-:|:-:|:-:|:-:|:-:| | ||
| [OpenVoice](https://github.com/myshell-ai/OpenVoice) | 13973 | 1213 | 2024-02-09 | Instant voice cloning by MyShell. | | ||
<!-- END_SECTION:reference-inspiration --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters