This project demonstrates a compelling use of AI technology for generating descriptive alt text for images, thus making web content more accessible.
Go to file
2024-06-25 17:29:39 +00:00
ai-alt-text-generator.sh Add ai-alt-text-generator.sh 2024-06-25 17:29:39 +00:00
README.md Add README.md 2024-06-25 17:28:58 +00:00

AI-Alt-Text-Generator

Overview

This project demonstrates a compelling use of AI technology for generating descriptive alt text for images, thus making web content more accessible.

While there are ethical considerations when using AI, this tool showcases how AI can be used for beneficial purposes rather than for unethical activities such as information theft. This project serves as a positive example of how AI can improve accessibility and provide meaningful benefits to users.

Description

This is a Bash script optimized for macOS that uses the OpenAI API to generate alt text for images. Users can choose to input an image URL or a local image file, which the script then processes to produce a detailed description of the image.

Prerequisites

Before using this script, ensure you have the following:

  • A macOS system.
  • A valid API key from OpenAI.
  • jq installed for JSON processing (brew install jq).
  • curl installed (usually pre-installed on macOS).

Installation

  1. Clone the Repository:

    git clone https://git.cyberwa.re/revengeday/ai-alt-text-generator.git
    cd ai-alt-text-generator
    
  2. Set Up the API Key:

    Open the script file and replace YOUR-API-KEY-HERE with your actual OpenAI API key.

    nano ai-alt-text-generator.sh
    
  3. Make the Script Executable:

    chmod +x ai-alt-text-generator.sh
    

Usage

1. Running the Script

Execute the script using the following command:

./ai-alt-text-generator.sh

2. Follow the Prompts

The script will interactively prompt you to choose between using an image URL or a local image file.

  • Use an Image URL:

    • Enter the image URL when prompted.
  • Use a Local Image File:

    • Ensure the image is in the same directory as the script or provide the correct path.
    • Enter the file name when prompted.

3. Wait for Processing

The script will display a waiting animation while it communicates with the OpenAI API. This process may take a few moments.

4. View the Result

The script will output the generated alt text, making your image accessible with a detailed description.

5. Generate More Alt Text (Optional)

You will be prompted to generate another alt text. You can choose "yes" to continue or "no" to exit.

Functions Explained

  • encode_image():

    • Base64 encodes a given image file, optimized for macOS.
  • show_wait_animation():

    • Displays a simple waiting animation during API processing.
  • generate_alt_text():

    • Main function that:
      • Prompts user for input type (URL or file).
      • Prepares the image data.
      • Sends a request to the OpenAI API.
      • Displays the generated alt text.

Ethical Considerations

Using AI technologies poses various ethical considerations. It's important to use these tools responsibly:

  • Transparency: Clearly indicate when content is AI-generated.
  • Privacy: Ensure AI is not used to infringe upon user privacy.
  • Bias: Be aware of and mitigate any biases that may be present in AI-generated content.
  • Usage: Promote positive and beneficial applications of AI, avoiding misuse such as unauthorized data access or harmful content generation.

Conclusion

This script is a practical implementation of AI that demonstrates its capability to enhance accessibility by generating descriptive alt texts for images. Its use case sheds light on the positive potential of AI, emphasizing the responsibility to use this technology ethically and effectively. Enjoy making your content more accessible and inclusive!


For more information, contributions, or issues, please visit the repository.