Skip to content

An REST API that consists of converting Text To Speech using the IBM Watson Cloud platform 💬

Notifications You must be signed in to change notification settings

matheus2x/smarkio-case-server

Repository files navigation

Logo


Summary

🤔 What is this?

This is the Server Side of my interview application in Smarkio.
Basically, a REST API that consists of converting text to speech using the IBM Watson Cloud platform.

Client-Side available: Here

🚀 Techs used

  • Node.js - A JavaScript Interpreter
  • TypeScript - A Superset for JavaScript
  • MySQL - A Relational Database
  • Knex.js - A SQL Query Builder
  • Docker - A Container Creator
  • Docker Compose - A Container Orchestrator

🔥 Getting started

  • You may need to install:

    • A Distributed Version-Control-System -> Git
    • A JavaScript Interpreter -> Node.js
    • Some Package Manager Like -> NPM or Yarn
    • The Relational Database -> MySQL
    • Container Docker -> Docker
    • Container Orchestrator Docker Compose -> Docker Compose
  • Others requirements:

    • A IBM Watson Cloud Account -> IBM-Register
    • On your IBM account, you will need to use the Text To Speech (TTS) service.
  1. Clone this repo with:
  $ git clone https://github.com/matheus2x/smarkio-case-server.git
  1. Move yourself to the appropriate directory: $ cd smarkio-case-server
  2. Rename .env.example to .env

Now, we have 2 paths: With Docker and Without Docker:

  • With Docker:

  1. In your .env file, add credentials for your IBM-Cloud Account (don't change the others environment vars):

    	TTS_API_KEY=		// REQUIRED
    	TTS_URL=		// REQUIRED
  2. Run $ docker-compose up --build -d to build docker-compose

  3. Run $ npm run populate to run migrations

  • Without Docker:

  1. To installing dependencies, run: $ npm install
  2. In your .env file, change values with your credentials:
	// Server
	NODE_PORT=3333		// OPTIONAL

	// MySQL
	MYSQL_HOST=		// without docker= REQUIRED
	MYSQL_USER=		// OPTIONAL
	MYSQL_PASS=		// OPTIONAL
	MYSQL_DB=		// without docker= REQUIRED

	// IBM Cloud
	TTS_API_KEY=		// REQUIRED
	TTS_URL=		// REQUIRED
  1. In your MYSQL, create a DB (with the same name as in your .env file):
CREATE DATABASE someDatabase;
  1. Run $ npm run build to compile ts build bundle
  2. Run $ npm run knex:migrate to run migrations
  3. Run $ npm run start to start server

If you've done Everything so far, you can now Start the Client-Side.


📙 API Usage

Attention: Omit the braces {} from examples. They indicate variable values

Routes

1. Create a new speechable comment:

Method: POST
Route: http://localhost:{NODE_PORT}/tts
Request Body:

	{
		"comment": String,
		"voiceLang": String // "1" to pt-br and "2" to en-us
	}

Response:

	{
		"id": Number,
		"comment": String,
		"audio": String // path to use
	}

2. Listen to the comment speech:

Method: GET
Route: http://localhost:{NODE_PORT}/uploads/speech-{commentID}.mp3
Output: audio.mp3 bynary file
Example: speech-1.mp3
Listen audio in Vocaroo: https://voca.ro/1kSLOdtoUecV

3. Index all comments in DB:

Method: GET
Route: http://localhost:{NODE_PORT}/tts

Response:

	[
		{
			"id": Number,
			"comment": String,
			"audio": String
		},
		{
			"id": Number,
			"comment": String,
			"audio": String
		},
		...
  ]

🔗 Useful URLs



Made with 🦊 by Matheus Henrique

About

An REST API that consists of converting Text To Speech using the IBM Watson Cloud platform 💬

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published