This project extracts handwritten text from an image using the Google Cloud Vision API and then sends the text to the OpenAI API to correct grammar and context issues.
- Python 3.9+
- A Google Cloud project with the Vision API enabled.
- A service account JSON file for the Google Cloud Vision API.
- An OpenAI API key.
- Clone the Repository
git clone https://your-repository-url.git
cd your-repository-folder- Create and Activate a Virtual Environment
python -m venv .venvActivate the virtual environment:
- macOS/Linux:
source .venv/bin/activate- Windows:
.venv\Scripts\activate- Install Dependencies
pip install -r requirements.txt- Set Up Environment Variables
Create a .env file in the root directory of the project with the following content:
OPENAI_API_KEY=your_openai_api_key
GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service_account.jsonMake sure the .env file is listed in your .gitignore file to keep your keys secure.
- Prepare Your Image
Place the image you want to process (e.g., redacao-02.png) in the project directory or update the image path in main.py.
To run the project, execute:
python main.pyThe script will:
- Extract handwritten text from the provided image using Google Cloud Vision.
- Send the extracted text to the OpenAI API for correction.
- Print both the extracted text and the corrected text in the console.
This project is licensed under the MIT License.