Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
|
@@ -7,6 +7,196 @@ sdk: docker
|
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
short_description: Structure recipe information from videos
|
|
|
|
| 10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
short_description: Structure recipe information from videos
|
| 10 |
+
|
| 11 |
---
|
| 12 |
+
# π½οΈ Recipe Extraction API
|
| 13 |
+
|
| 14 |
+
This project is a Flask-based API that extracts structured recipe information from cooking tutorial videos! It uses the **Deepgram API** for audio transcription, **Tesseract OCR** for text extraction from video frames, and the **Gemini API** to generate a well-structured recipe document. π
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## π¦ Project Setup
|
| 19 |
+
|
| 20 |
+
Follow these steps to set up and run the project on your local machine.
|
| 21 |
+
|
| 22 |
+
### 1οΈβ£ Clone the Repository
|
| 23 |
+
|
| 24 |
+
```bash
|
| 25 |
+
git clone <your-repo-url>
|
| 26 |
+
cd <your-repo-folder>
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
### 2οΈβ£ Install Dependencies
|
| 30 |
+
|
| 31 |
+
Make sure you have Python installed (Python 3.8 or above is recommended). Install the required libraries using pip:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
pip install -r requirements.txt
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### 3οΈβ£ Install Tesseract OCR
|
| 38 |
+
|
| 39 |
+
Ensure **Tesseract OCR** is installed on your system. You can download it here: [Tesseract GitHub](https://github.com/tesseract-ocr/tesseract)
|
| 40 |
+
|
| 41 |
+
Add Tesseract to your system path and make sure to note its installation location.
|
| 42 |
+
|
| 43 |
+
#### On Windows:
|
| 44 |
+
|
| 45 |
+
Add the path to `tesseract.exe` to your environment variables, e.g.:
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
C:\Program Files\Tesseract-OCR
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
#### On MacOS (using Homebrew):
|
| 52 |
+
|
| 53 |
+
```bash
|
| 54 |
+
brew install tesseract
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
#### On Ubuntu:
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
sudo apt-get install tesseract-ocr
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### 4οΈβ£ Setup Environment Variables
|
| 64 |
+
|
| 65 |
+
Create a `.env` file in the root directory and add your API keys:
|
| 66 |
+
|
| 67 |
+
```plaintext
|
| 68 |
+
FIRST_API_KEY=<Your Gemini API Key>
|
| 69 |
+
SECOND_API_KEY=<Your Deepgram API Key>
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
### 5οΈβ£ Install FFmpeg
|
| 73 |
+
|
| 74 |
+
This project uses **FFmpeg** for converting MP4 videos to WAV audio. Install it via the following:
|
| 75 |
+
|
| 76 |
+
#### On MacOS (using Homebrew):
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
brew install ffmpeg
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
#### On Ubuntu:
|
| 83 |
+
|
| 84 |
+
```bash
|
| 85 |
+
sudo apt-get install ffmpeg
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
#### On Windows:
|
| 89 |
+
|
| 90 |
+
Download FFmpeg from [FFmpeg.org](https://ffmpeg.org/download.html) and add it to your system path.
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## π Running the Project
|
| 95 |
+
|
| 96 |
+
Start the Flask server with the following command:
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
python app.py
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
If everything is set up correctly, you should see:
|
| 103 |
+
|
| 104 |
+
```plaintext
|
| 105 |
+
* Running on http://127.0.0.1:5000/
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
+
|
| 110 |
+
## π‘ API Endpoints
|
| 111 |
+
|
| 112 |
+
### β
Health Check
|
| 113 |
+
|
| 114 |
+
**Endpoint:** `GET /`
|
| 115 |
+
|
| 116 |
+
Check if the API is running.
|
| 117 |
+
|
| 118 |
+
```bash
|
| 119 |
+
curl http://127.0.0.1:5000/
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
**Response:**
|
| 123 |
+
|
| 124 |
+
```json
|
| 125 |
+
{
|
| 126 |
+
"status": "success",
|
| 127 |
+
"message": "API is running successfully!"
|
| 128 |
+
}
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### π² Recipe Extraction
|
| 132 |
+
|
| 133 |
+
**Endpoint:** `POST /process-video`
|
| 134 |
+
|
| 135 |
+
#### Request Body:
|
| 136 |
+
|
| 137 |
+
Send a JSON payload with a video URL:
|
| 138 |
+
|
| 139 |
+
```json
|
| 140 |
+
{
|
| 141 |
+
"videoUrl": "<URL-of-the-cooking-video>"
|
| 142 |
+
}
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
#### Example Using `curl`:
|
| 146 |
+
|
| 147 |
+
```bash
|
| 148 |
+
curl -X POST http://127.0.0.1:5000/process-video \
|
| 149 |
+
-H "Content-Type: application/json" \
|
| 150 |
+
-d '{"videoUrl": "https://example.com/video.mp4"}'
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
#### Sample Response:
|
| 154 |
+
|
| 155 |
+
```json
|
| 156 |
+
{
|
| 157 |
+
"**1. Recipe Name:**": "Beef Wellington",
|
| 158 |
+
"**2. Ingredients List:**": "* Fillet of beef\n* Olive oil\n* Salt\n* Pepper",
|
| 159 |
+
"**3. Steps for Preparation:**": "1. Sear the beef fillet\n2. Brush with mustard",
|
| 160 |
+
"**4. Cooking Techniques Used:**": "* Searing\n* Wrapping",
|
| 161 |
+
"**5. Equipment Needed:**": "* Hot pan\n* Blender",
|
| 162 |
+
"**6. Nutritional Information:**": "High in protein and fat",
|
| 163 |
+
"**7. Serving size:**": "2-4 people",
|
| 164 |
+
"**8. Special Notes or Variations:**": "Use horseradish instead of mustard",
|
| 165 |
+
"**9. Festive or Thematic Relevance:**": "Christmas alternative to roast turkey"
|
| 166 |
+
}
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
## π οΈ Key Features
|
| 172 |
+
|
| 173 |
+
- **Deepgram API** for accurate audio transcription.
|
| 174 |
+
- **Tesseract OCR** for extracting text from video frames.
|
| 175 |
+
- **Gemini API** for generating structured recipe information.
|
| 176 |
+
- **FFmpeg** for seamless MP4-to-WAV conversion.
|
| 177 |
+
- Supports both audio and video analysis for enhanced accuracy. π―
|
| 178 |
+
|
| 179 |
+
---
|
| 180 |
+
|
| 181 |
+
## π§ͺ Testing
|
| 182 |
+
|
| 183 |
+
Use tools like **Postman** or **curl** to test the API endpoints.
|
| 184 |
+
|
| 185 |
+
---
|
| 186 |
+
|
| 187 |
+
## π€ Contributions
|
| 188 |
+
|
| 189 |
+
Contributions are welcome! Feel free to submit a pull request or open an issue for any enhancements or bug fixes.
|
| 190 |
+
|
| 191 |
+
---
|
| 192 |
+
|
| 193 |
+
## π License
|
| 194 |
+
|
| 195 |
+
This project is licensed under the MIT License.
|
| 196 |
+
|
| 197 |
+
---
|
| 198 |
+
|
| 199 |
+
### π Happy Coding and Bon AppΓ©tit! π¨βπ³π©βπ³
|
| 200 |
+
|
| 201 |
|
| 202 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|