CameraApp is a Python application that integrates OpenAI's GPT-4 Vision API and Audio API to capture an image using a laptop camera, interpret the image using AI, and provide an audio output of the AI's description.
- Capture images from a specified camera index.
- Encode the image to a base64 string.
- Send the encoded image to OpenAI's API for interpretation.
- Convert the API's text response to audio.
- Calculate the cost of API usage based on token count.
Before you begin, ensure you have met the following requirements:
- Python 3.10.7+
- OpenAI Python library
- OpenCV-Python library
- A valid OpenAI API key
Clone the repository to your local machine:
git clone https://github.com/klapp101/camera-app.gitNavigate to the project directory:
cd camera-appInstall the required Python packages:
pip install openai opencv-python requestsTo use CameraApp, follow these steps:
- Replace
'API_KEY_HERE'with your actual OpenAI API key.
client = OpenAI(api_key='YOUR_API_KEY')- Initialize the CameraApp with the appropriate camera index and your OpenAI API key.
camera_app = CameraApp(camera_index=0, api_key='YOUR_API_KEY')-
Call the
capture_imagemethod to take a picture with the camera. -
The image will be processed, and the AI's interpretation will be output as an audio file named
output.mp3.
To contribute to CameraApp, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>. - Make your changes and commit them:
git commit -m '<commit_message>' - Push to the original branch:
git push origin <project_name>/<location> - Create the pull request.
Alternatively, see the GitHub documentation on creating a pull request.
If you want to contact me you can reach me at ryan.klapper.ma@gmail.com.