- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π License
- π Authors
This repository houses a Minimum Viable Product (MVP) for a Deno API built to convert text to speech using Deepgram's powerful voice models. The API simplifies the integration of speech capabilities into applications, addressing the growing need for on-demand speech generation across diverse platforms like chatbots, interactive voice assistants, accessibility tools, and educational resources. The MVP utilizes a robust tech stack including Deno, FastAPI, PostgreSQL, Deepgram, and Upstash for rate limiting, ensuring efficient and secure operation.
Feature | Description | |
---|---|---|
βοΈ | Architecture | The API is designed with a modular architecture, separating functionalities into distinct files and directories for enhanced maintainability and scalability. |
π | Documentation | This README provides a detailed overview of the API, its features, installation instructions, usage examples, and deployment guidelines. |
π | Dependencies | The API leverages external libraries and packages including FastAPI, SQLAlchemy, Deepgram, Upstash, and other essential dependencies for core functionality and integration. |
𧩠| Modularity | The modular code structure promotes reusability and eases maintenance. Specific functionalities, like authentication, rate limiting, and speech generation, are encapsulated in dedicated modules. |
π§ͺ | Testing | Thorough unit tests and integration tests are implemented to guarantee the reliability and correctness of the API's functionality. |
β‘οΈ | Performance | The API is optimized for performance, incorporating caching strategies and efficient data management to handle high volumes of requests. |
π | Security | Robust security measures, including input validation, authentication, and data encryption, are implemented to protect user data and prevent unauthorized access. |
π | Version Control | The project utilizes Git for version control with continuous integration and continuous delivery (CI/CD) implemented using GitHub Actions for automated builds and releases. |
π | Integrations | The API seamlessly integrates with external services through HTTP requests, including the Deepgram API for speech synthesis and Upstash for rate limiting and caching. |
πΆ | Scalability | The architecture is designed for scalability to handle increasing user demand. The API can be easily scaled horizontally and vertically based on traffic patterns. |
deno-deepgram-text-to-speech-api/
βββ app
β βββ main.py
β βββ models
β β βββ user.py
β βββ routers
β β βββ speech.py
β βββ services
β β βββ speech_service.py
β βββ utils
β β βββ auth.py
β β βββ rate_limiter.py
β βββ config
β β βββ database.py
β βββ database.py
βββ tests
β βββ test_speech.py
βββ requirements.txt
βββ .env
- Python 3.9+
- pip
- Docker
- Docker Compose
- Clone the repository:
git clone https://github.com/spectra-ai-codegen/deno-deepgram-text-to-speech-api.git
- Navigate to the project directory:
cd deno-deepgram-text-to-speech-api
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
- Create a
.env
file in the project root. - Add the following environment variables:
DEEPGRAM_API_KEY
: Your Deepgram API key.UPSTASH_REDIS_URL
: Your Upstash Redis connection URL.DATABASE_URL
: Your PostgreSQL database connection URL.
- Create a
- Start the API:
uvicorn app.main:app --reload
- Database configuration is in
app/config/database.py
. - Authentication and authorization are managed in
app/utils/auth.py
. - Rate limiting is configured in
app/utils/rate_limiter.py
.
- Example 1: Generate speech from text
curl -X POST "http://localhost:8000/speech" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello, world!", "model_id": "deepgram_model_id" }'
- Build Docker image:
docker build -t deno-deepgram-text-to-speech-api .
- Start a Docker container:
docker run -d -p 8000:8000 deno-deepgram-text-to-speech-api
- Access the API:
- The API is accessible at
http://localhost:8000
.
- The API is accessible at
DEEPGRAM_API_KEY
: Your Deepgram API key.UPSTASH_REDIS_URL
: Your Upstash Redis connection URL.DATABASE_URL
: Your PostgreSQL database connection URL.
- POST
/speech
: Converts text to speech.- Request body:
{ "text": "The text to convert to speech.", "model_id": "The Deepgram voice model ID." }
- Response body:
{ "audio_url": "The URL of the generated audio file." }
- Request body:
- The API uses JWT authentication to secure endpoints.
- Generate speech using the API:
curl -X POST "http://localhost:8000/speech" \ -H "Content-Type: application/json" \ -d '{ "text": "This is a test.", "model_id": "deepgram_model_id" }'
This project is licensed under the MIT License - see the LICENSE file for details.
- Author Name - Spectra.codes
- Creator Name - DRIX10
Why only generate Code? When you can generate the whole Repository!