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.
- 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.
- 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.)
- Raspberry Pi 5 (recommended)
- Python 3.8+
- pip
- Clone the repository:
git clone https://github.com/frolicxpg/LeoAPI.git cd LeoAPI - Install dependencies:
pip install -r requirements.txt
- Configure environment variables:
- Copy
.env.exampleto.envand fill in required values (OpenAI API keys, etc.).
- Copy
python app.pyThe Flask server will start, ready to process requests from local IoT nodes or mobile clients.
├── 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
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
Contributions and suggestions are welcome. Please open issues or pull requests for improvements.
No license specified.
Developed by frolicxpg.