Backend API for POINT
This backend service provides location-based descriptions using Claude AI and converts them into speech using ElevenLabs' text-to-speech API. Users can request information about a place, and the service will generate an audio file that describes the location.
- Fetch brief descriptions of locations using Claude AI
- Convert descriptions into speech using ElevenLabs
- Serve the generated audio files via API
- Logging and environment-based configuration support
- Python (Flask)
- Claude AI API (Anthropic)
- ElevenLabs Text-to-Speech API
- dotenv for environment variable management
- Logging for debugging and monitoring
- Python 3.8+
pip
installed- API keys for Claude AI and ElevenLabs
.env
file with the required API credentials
-
Clone the repository:
git clone https://github.com/{yourusername}/BuildathonBackend.git cd BuildathonBackend
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `source venv/Scripts/activate` for bash or venv\Scripts\activate in cmd
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and add the following:#API Key CLAUDE_API_KEY = "skxxx" ELEVENLABS_API_KEY = "skxxx" #DEFAULT CLAUDE_MODEL = "claude-3-opus-20240229" ELEVENLABS_API_URL = "https://api.elevenlabs.io/v1/text-to-speech" CLAUDE_API_URL = "https://api.anthropic.com/v1/messages" ELEVENLABS_VOICE_ID = "21m00Tcm4TlvDq8ikWAM"
-
Start the server:
python main.py
The server should now be running on
http://127.0.0.1:5000/
.
- Endpoint:
/health
- Method:
GET
- Response:
{"status": "healthy"}
- Endpoint:
/get-location-audio
- Method:
GET
- Query Parameters:
place
: The name of the location (e.g.,?place=Paris
)
- Response:
- Returns an MP3 audio file with the location description.
- If an error occurs, returns a JSON error response.
- Endpoint:
/get-location-info
- Method:
GET
- Query Parameters:
place
: The name of the location (e.g.,?place=Paris
)
- Response:
{ "place": "Paris", "description": "Now approaching the Eiffel Tower, a symbol of France..." }
Logging is handled via logging_util.py
, configured through the config.py
file. The log level can be adjusted based on the FLASK_ENV
variable.
- Ensure
FLASK_ENV=production
in the.env
file. - Use a production-ready server like Gunicorn:
gunicorn -w 4 -b 0.0.0.0:5000 app:app
- Fork the repository
- Create a new feature branch
- Commit your changes
- Push to your branch
- Open a Pull Request
This project is licensed under the MIT License.