Skip to main content

A Python package for transcribing audio files, summarizing text, and extracting information using Gemini AI and Pydantic.

Project description

Mantis

Mantis is a Python package for transcribing audio files, summarizing text, and extracting information using Gemini AI and Pydantic. It provides simple interfaces to transcribe MP3 files, summarize text, and extract key information effortlessly.

📚 Documentation

Documentation Status

The comprehensive documentation is available at https://mantis.readthedocs.io.

🛠️ Features

  • Easy Transcription: Transcribe MP3 files or YouTube URLs with a single function call.
  • Data Validation: Ensures input and output data integrity using Pydantic.
  • Integration with Gemini AI: Leverages Gemini AI's powerful language models for accurate transcriptions, summaries, and extractions.
  • YouTube Support: Stream audio directly from YouTube URLs without downloading the entire file.
  • Command-Line Interface (CLI): Interact with Mantis directly from the terminal.
  • Comprehensive Testing: Robust unit tests ensure reliability.
  • Continuous Integration: Automated testing and linting with GitHub Actions.
  • Comprehensive Documentation: Generated with Sphinx and hosted on Read the Docs.

🚀 Installation

To install Mantis, run the following command:

pip install mantis

Alternatively, install it in editable mode for development purposes:

pip install -e .

🧑‍💻 Usage

🖥️ Command-Line Interface (CLI)

After installation, you can use the mantis CLI to transcribe, summarize, and extract information from audio files or YouTube URLs.

mantis [command] [arguments]

Available Commands:

  • transcribe: Transcribe audio from a file or YouTube URL.
  • summarize: Summarize audio from a file or YouTube URL.
  • extract: Extract information from audio with a custom prompt.

Examples:

  • Transcribe a local MP3 file:

    mantis transcribe path/to/your/audio.mp3
    
  • Transcribe a YouTube URL:

    mantis transcribe https://www.youtube.com/watch?v=AKJfakEsgy0&ab_channel=MrBeast
    
  • Summarize a local MP3 file:

    mantis summarize path/to/your/audio.mp3
    
  • Summarize a YouTube URL:

    mantis summarize https://www.youtube.com/watch?v=AKJfakEsgy0&ab_channel=MrBeast
    
  • Extract information from a local MP3 file with a custom prompt:

    mantis extract path/to/your/audio.mp3 --prompt "Extract key points from this audio."
    
  • Extract information from a YouTube URL with a custom prompt:

    mantis extract https://www.youtube.com/watch?v=AKJfakEsgy0&ab_channel=MrBeast --prompt "Extract key points from this audio."
    

📝 Python API

You can also use Mantis programmatically in your Python scripts:

import os
from mantis import transcribe, summarize, extract
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

def main():
    try:
        # Example usage for transcription using a local file path
        transcription_result = transcribe("path/to/your/audio.mp3")
        print("Transcription (Local File):", transcription_result.transcription)

        # Example usage for transcription using a YouTube URL
        youtube_url = "https://www.youtube.com/watch?v=AKJfakEsgy0&ab_channel=MrBeast"
        transcription_youtube = transcribe(youtube_url)
        print("\nTranscription (YouTube URL):", transcription_youtube.transcription)

        # Example usage for summarization using a local file path
        summary_result = summarize("path/to/your/audio.mp3")
        print("\nSummary (Local File):", summary_result.summary)

        # Example usage for summarization using a YouTube URL
        summary_youtube = summarize(youtube_url)
        print("\nSummary (YouTube URL):", summary_youtube.summary)

        # Example usage for extraction using a local file path and a custom prompt
        extraction_result = extract(
            "path/to/your/audio.mp3",
            "Extract key points from this audio."
        )
        print("\nExtraction (Local File):", extraction_result.extraction)

        # Example usage for extraction using a YouTube URL and a custom prompt
        extraction_youtube = extract(
            youtube_url,
            "Extract key points from this audio."
        )
        print("\nExtraction (YouTube URL):", extraction_youtube.extraction)
    except Exception as error:
        print(f"An error occurred: {error}")

if __name__ == "__main__":
    main()

📦 Installation

To install Mantis, please refer to the Installation section above.

🔐 Environment Variables

Mantis requires certain environment variables to function correctly. Please refer to the .env.example file for the necessary configurations.

  1. Create a .env File:

    cp .env.example .env
    
  2. Fill in the Required Values:

    Open the .env file in your preferred text editor and replace the placeholder values with your actual credentials.

    GEMINI_API_KEY=your_gemini_api_key_here
    

Note: Ensure that your .env file is added to .gitignore to prevent accidental exposure of sensitive information.

📄 License

This project is licensed under the Apache License 2.0.

🙌 Contributing

Contributions are welcome! Please refer to the CONTRIBUTING guide for more details.

📜 Code of Conduct

Please read our Code of Conduct to understand our expectations for participant behavior.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mantisai-0.1.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mantisai-0.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file mantisai-0.1.1.tar.gz.

File metadata

  • Download URL: mantisai-0.1.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for mantisai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 989249a26ada3d7d9ed016b2d4b0469ed325bb8eba56e81a2ff4018cc6b5f24a
MD5 e083db6796fc7a998575b1f0480d429f
BLAKE2b-256 9abd499f513f9883d3a1ff9d4468635e68ec7703112ee67cccb2b39b8cb68bd0

See more details on using hashes here.

File details

Details for the file mantisai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mantisai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for mantisai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b7235c9fdc98754be32cc187c5c2eac0a01b542e9303682072afd8faa165f3b
MD5 553b03902864b1792cfc5a0c498738b7
BLAKE2b-256 fcfe09a24f30ce8f4d20cf6472a63296886fe2c9092d1a08976a62d542a42bee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page