Skip to content

frolicxpg/LeoAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeoAPI: AI Home Assistant Cloud API

LeoAPI is a Python-powered cloud API designed to enable advanced AI voice assistant functionality for smart home automation. Hosted on a Raspberry Pi 5, LeoAPI provides fast, scalable speech recognition, natural language understanding, and smart device control through RESTful endpoints. It is engineered for seamless integration with local IoT nodes, such as a Raspberry Pi Zero 2W voice client, but this repository focuses on the cloud API server.

For setting up Pi Zero 2W IoT devices, check out the companion repository: frolicxpg/LeoIoT.

Key Features

  • Speech Recognition: Vosk model integration for efficient, multi-language voice transcription.
  • Language Detection: Automated language identification using langdetect.
  • Conversational AI: OpenAI GPT API for natural, context-aware responses.
  • Text-to-Speech: Converts AI responses to voice using OpenAI TTS API.
  • Smart Home Control: API endpoints for controlling devices like lights and more.

System Architecture

  • Cloud AI Server (this repo): Runs on Raspberry Pi 5, handles all heavy processing (speech, language, AI) and exposes RESTful endpoints for local clients to connect.
  • Local IoT Node (introduced): Example: Raspberry Pi Zero 2W with ReSpeaker 2-Mic Pi Hat acts as a voice input/output device, streaming audio to the cloud API and playing responses. (Setup for IoT node is not covered here.)

Quick Start

Prerequisites

  • Raspberry Pi 5 (recommended)
  • Python 3.8+
  • pip

Installation

  1. Clone the repository:
    git clone https://github.com/frolicxpg/LeoAPI.git
    cd LeoAPI
  2. Install dependencies:
    pip install -r requirements.txt
  3. Configure environment variables:
    • Copy .env.example to .env and fill in required values (OpenAI API keys, etc.).

Running the API

python app.py

The Flask server will start, ready to process requests from local IoT nodes or mobile clients.

Project Structure

├── app.py             # Main Flask API server
├── chat_handler.py    # Chat and conversation logic
├── functions/         # Modular utility code
├── messages.json      # Templates/data for messages
├── requirements.txt   # Python dependencies
├── .env.example       # Example environment config
└── .gitignore         # Git ignore rules

Integrating IoT Voice Node

To use LeoAPI with a local IoT node (e.g., Pi Zero 2W with voice hardware), configure the client to stream voice data to the LeoAPI endpoint. The cloud server will handle speech-to-text, AI response, and TTS, returning synthesized speech for playback.

For Pi Zero 2W hardware setup and IoT client configuration, refer to the companion project: frolicxpg/LeoIoT

Contributing

Contributions and suggestions are welcome. Please open issues or pull requests for improvements.

License

No license specified.

Author

Developed by frolicxpg.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages