Skip to content

This is an Express API that provides various endpoints to build applications that can generate text completion and speech synthesis using the OpenAI's GPT-3 model and the VoiceRSS API.

License

Notifications You must be signed in to change notification settings

YacineSteeve/nova-voicebot-api

Repository files navigation

NOVA API

Test Release (latest)

Logo



This is an Express API that provides various endpoints to build applications that can generate text completion and speech synthesis using the OpenAI's GPT-3 model and the VoiceRSS API.

Usage

The API is hosted on Heroku. So you can use it without having to install it locally.

Here's a list of all the available endpoints:

Welcome

  • GET /

This endpoint returns a welcome message to confirm that the API is up and running.

Request
GET /
Response
Welcome to the NOVA API!

Completion

  • POST /api/completion

    This endpoint takes in a request body containing a text prompt and returns the completion of that prompt using the OpenAI's GPT-3 model.
Request
POST /api/completion
Content-Type: application/json
Authorization: Bearer <token>

{
    "prompt": string;
    "user": string;
}
Response
Accept: application/json

{
    "success": true;
    "completion": {
        "id": string;
        "object": "text_completion",
        "created": number;
        "model": "text-davinci-003",
        "choices": [
            {
              "text": string; # The actual completion
              "index": 0,
              "logprobs": null,
              "finish_reason": string;
            }
        ],
        "usage": {
            "prompt_tokens": number;
            "completion_tokens": number;
            "total_tokens": number;
        }
    }
}

Speech

  • POST /api/speech

    This endpoint takes in a request body containing a text input and returns the speech synthesis of that text.
Request
POST /api/speech
Content-Type: application/json
Authorization: Bearer <token>

{
    "text": string;
    "lang"?: string;   # Default: "en-US"
    "speed"?: string;  # Default: "0"
    "codec"?: string;  # Default: "mp3"
    "format"?: string; # Default: "8khz_8bit_mono"
    "b64"?: string;    # Default: "true"
}
Response
Accept: application/json

{
    "success": true;
    "speech": string; # "Base64-encoded audio"
}

User

  • POST /user/signup

    This endpoint creates a new user account.
Request
POST /user/signup
Content-Type: application/json

{
    "email": string;
    "password": string;
}
Response
Accept: application/json

{
    "success": true;
    "user": {
        "username": string;
        "email": string;
    }
}
  • POST /user/login

    This endpoint logs in an existing user.
Request
POST /user/login
Content-Type: application/json

{
    "email": string;
    "password": string;
}
Response
Accept: application/json

{
    "success": true;
    "token": string; # User token, expires in 1 day
}
  • POST /user/userinfo

    This endpoint returns user information based on the token provided in the request.
Request
POST /user/userinfo
Content-Type: application/json

{
    "token": string; # User token
}
Response
Accept: application/json

{
    "success": true;
    "user": {
        "username": string;
        "email": string;
    }
}
  • POST /user/delete

    This endpoint deletes a user account based on the token provided in the request.
Request
POST /user/delete
Content-Type: application/json

{
    "token": string;
}
Response
Accept: application/json

{
    "success": true;
}

Support

  • POST /support/contact

    This endpoint sends an email to the NOVA support team.
Request
POST /support/contact
Content-Type: application/json

{
    "name": string;
    "email": string;
    "subject": string;
    "message": string;
}
Response
Accept: application/json

{
    "success": true;
    "message": "Message sent successfully";
    "info": SMTPTransport.SentMessageInfo; # See https://nodemailer.com/message/
}

Errors

All errors are returned in the following format:

Status: <status code>

{
    "success": false;
    "error": string;
    "fields"?: string[];
    "categories"?: string[]; # Only for /api/completion, when the prompt is against OpenAI's guidelines
}

Installation

Prerequisites

Setup

  1. Clone the repository
git clone https://github.com/YacineSteeve/nova-voicebot-api.git
  1. Install dependencies
yarn install
  1. Add environment variables:
  • Create a .env file in the root directory
  • add the environment variables listed in the .env.example file.

Note: NODE_ENV should be set to development.

  1. Start the server
yarn dev

License

MIT

Author

Yacine BOUKARI

About

This is an Express API that provides various endpoints to build applications that can generate text completion and speech synthesis using the OpenAI's GPT-3 model and the VoiceRSS API.

Topics

Resources

License

Stars

Watchers

Forks