-
Notifications
You must be signed in to change notification settings - Fork 471
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
1f55723
commit 7a4b4ae
Showing
5 changed files
with
84 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Deploy Speech Models to Cloud RUN | ||
|
||
# TODO: determine if changes to backend folder before pushing | ||
|
||
on: | ||
push: | ||
branches: [ "main", "development" ] | ||
paths: | ||
- 'backend/modal/**' | ||
|
||
env: | ||
SERVICE: backend | ||
REGION: us-central1 | ||
|
||
jobs: | ||
deploy: | ||
environment: ${{ (github.ref == 'refs/heads/development' && 'development') || (github.ref == 'refs/heads/main' && 'prod') }} | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Google Auth | ||
id: auth | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | ||
- run: gcloud auth configure-docker | ||
- name: Build and Push Docker image | ||
run: | | ||
docker build -t gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }} -f backend/modal/Dockerfile . | ||
docker push gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }} | ||
- name: Deploy to Cloud Run | ||
id: deploy | ||
uses: google-github-actions/deploy-cloudrun@v0 | ||
with: | ||
service: ${{ env.SERVICE }} | ||
region: ${{ env.REGION }} | ||
image: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }} | ||
|
||
# If required, use the Cloud Run url output in later steps | ||
- name: Show Output | ||
run: echo ${{ steps.deploy.outputs.url }} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM tiangolo/uvicorn-gunicorn:python3.11 | ||
|
||
RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl | ||
RUN apt-get install unzip | ||
RUN apt-get -y install python3 | ||
RUN apt-get -y install python3-pip | ||
RUN apt-get -y install git | ||
RUN apt-get -y install ffmpeg | ||
|
||
COPY backend/requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
COPY backend/ /app | ||
|
||
EXPOSE 8080 | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import List | ||
|
||
from fastapi import FastAPI, UploadFile, File, Form | ||
|
||
from speech_profile_modal import ResponseItem, endpoint as speaker_identification_endpoint | ||
from vad_modal import endpoint as vad_endpoint | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.post('/v1/speaker-identification') | ||
def speaker_identification( | ||
uid: str, audio_file: UploadFile = File, segments: str = Form(...) | ||
) -> List[ResponseItem]: | ||
return speaker_identification_endpoint(uid, audio_file, segments) | ||
|
||
|
||
@app.post('/v1/vad') | ||
def vad(audio_file: UploadFile = File): | ||
return vad_endpoint(audio_file) |
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