Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team Catapult #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 46 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
# Gen-Ai-Rush-Buildathon

## Submission Instruction:
1. Fork this repository
2. Create a folder with your Team Name
3. Upload all the code and necessary files in the created folder
4. Upload a **README.md** file in your folder with the below mentioned informations.
5. Generate a Pull Request with your Team Name. (Example: submission-XYZ_team)
![logo](catapult/logoavatar.png)

## README.md must consist of the following information:

#### Team Name -
#### Team Name - Catapult
#### Problem Statement -
Many candidates, especially from lower social tiers, lack real-world interview experience and struggle with nervousness, leading to suboptimal performance in actual interviews. Existing interview preparation methods often fall short in providing sufficient practice opportunities and personalized feedback.
#### Team Leader Email -

shreeyash dot s dot pawar at gmail.com
## A Brief of the Prototype:
This section must include UML Diagrams and prototype description


## Tech Stack:
List Down all technologies used to Build the prototype

![architecture](catapult/backend/arch.png)
## Step-by-Step Code Execution Instructions:
This Section must contain a set of instructions required to clone and run the prototype so that it can be tested and deeply analyzed
## Catapult Frontend

## React JS
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

Node version : 16.17

### Setup

Go to the `catapult-frontend` folder ->

1. `node --version` -- needs 16.17
2. `npm install`
(if dependency error is shown - run `npm install --force` instead)
3. Verify details in `/src/config.js` file
4. `npm start`

## Catapult Backend
### FastAPI + Speech Processing + Video Generation

#

#### Setup

Go to `catapult-backend` folder ->

1. `python3 --version` -- needs 3.11
2. `python3 -m venv env_dev`
3. `source ./env_dev/bin/activate`
4. `pip install -r requirements.txt`
4. Verify detials in `.env` file
5. `python3 -m uvicorn main:app --reload`




## What I Learned:
Write about the biggest learning you had while developing the prototype
## What we Learned:
Working with LLM's and NLP
AI talking head generation landscape and models
Multimedia streaming (most difficult!)
Advanced FastAPI
34 changes: 34 additions & 0 deletions catapult/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Catapult Frontend

## React JS
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

Node version : 16.17

### Setup

Go to the `catapult-frontend` folder ->

1. `node --version` -- needs 16.17
2. `npm install`
(if dependency error is shown - run `npm install --force` instead)
3. Verify details in `/src/config.js` file
4. `npm start`

# Catapult Backend
### FastAPI + Speech Processing + Video Generation

#

#### Setup

Go to `catapult-backend` folder ->

1. `python3 --version` -- needs 3.11
2. `python3 -m venv env_dev`
3. `source ./env_dev/bin/activate`
4. `pip install -r requirements.txt`
4. Verify detials in `.env` file
5. `python3 -m uvicorn main:app --reload`


Binary file added catapult/backend/arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions catapult/backend/ffmpeg_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import ffmpeg
import subprocess
import cv2
from queue import Queue
import wave
from pydub import AudioSegment

#video_format = "hls"
video_format = "flv"
#server_url = "stream_output/playlist.m3u8"
server_url = "http://localhost:8081/stream"
video_path = "videoQuestion.mp4"
#audio_path = "audio_files/mySound.wav"


def start_streaming(width, height, fps, audio_file):
video_stream = ffmpeg.input(
"pipe:",
format="rawvideo",
codec="rawvideo",
pix_fmt="bgr24",
s="{}x{}".format(width, height),
)

#audio_stream = ffmpeg.input(audio_file)

process = (
ffmpeg.output(
video_stream,
server_url,
format=video_format,
listen=1,
pix_fmt="yuv420p",
preset="ultrafast",
#hls_list_size=10, # the maximum number of playlist entries
#hls_flags="delete_segments", # delete segments from the playlist file as they become unavailable
)
# .global_args("-re") # argument to act as a live stream
.overwrite_output().run_async(pipe_stdin=True)
)
return process


def init_cap():
cap = cv2.VideoCapture(video_path)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
return cap, width, height


def run(audio_file=None):
cap, width, height = init_cap()
print(width, height)
fps = cap.get(cv2.CAP_PROP_FPS)
streaming_process = start_streaming(width, height, fps, audio_file)

# while True:
# while True:
# ret, frame = cap.read()
# if ret:
# streaming_process.stdin.write(frame.tobytes())
# else:
# break

# cap.release()
# cap, width, height = init_cap()

while True:
ret, frame = cap.read()
print(frame.shape,type(frame),frame.dtype,frame[0,0])
if ret:
streaming_process.stdin.write(frame.tobytes())
else:
break

cap.release()

streaming_process.stdin.close()
streaming_process.wait()

if __name__=="__main__":
run()
47 changes: 47 additions & 0 deletions catapult/backend/hls_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from fastapi import FastAPI, HTTPException
from fastapi.staticfiles import StaticFiles
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.responses import Response
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware import Middleware
from dotenv import load_dotenv
import os

from fastapi.responses import FileResponse
from pathlib import Path


class CacheMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
response = await call_next(request)
response.headers["Cache-Control"] = "no-store, max-age=0"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
return response


load_dotenv()


# Handling envs
origins = os.getenv("FRONTEND_ORIGINS")
if not origins:
raise Exception("FRONTEND_ORIGINS env not found. Exiting...")

middleware = [
Middleware(
CORSMiddleware,
allow_origins=origins.split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"],
)
]

app = FastAPI(middleware=middleware)


app.add_middleware(CacheMiddleware)

app.mount("/stream", StaticFiles(directory="stream_output"), name="static")
Loading