TTS-STT – Text To Speech & Speech To Text

tts-stt

TTS-STT is a Python & Flask power, easy-to-use system that helps you to convert Text to Speech or Speech to Text using a small web app.

Features

  • Detecting the language of the text.
  • Selecting the TTS Voice.
  • Converting Speech to Text (Up to 1 minute long)

Components and Frameworks used in TTS-STT

The TTS (Text to Speech) feature is free thanks to Reverso Translations, But the Speech To Text feature requires an active google API cloud account with an enabled billing account (pricing table can be found here).

Installation

To use Google Speech Recognition, we need to create Google Application and enable the API. Here are the steps you need to follow to integrate your program with the Google Speech-To-Text API.

Step 1) Create a Google Application

The first thing you need to access Google APIs is a Google account and create a Google application. You can create a google application using the google console: Go to google console.

Once you open the google console, click on the dropdown at the top. This dropdown displays your existing google application. After clicking, a pop-up will appear, then click on “New Project.”

TTS-STT - Google Application
TTS-STT - New Application

Then enter your application name and click on Create.

Step 2) Enable Cloud Speech-To-Text API

Once you have created your google application, you need to grant your application access to the “Google Cloud Speech-To-Text” API. To do so, go to the application dashboard and, from there, go to the APIs overview. See below how to access it:

TTS-STT - APIs overview - Tomer Klein

Click on “Enable Apis and Service,” and then search by “speech,” then all Google APIs to do with text will be listed.

TTS-STT - Enable Apis and Service
Enable STT

And then click “Enable.” Once enabled, you will grant permissions to your application to access the “Google Cloud Speech to Text API.”

Step 3) Download Google Credentials

The next step is Downloading your Google credentials. The credentials are necessary so Google can authenticate your application, and therefore Google knows that their API is being accessed by you. They can measure how much you are using their APIs and charge you if the consumption passes the free threshold.

Here are the steps to download the google credentials. First, from the home dashboard, get to “Go to APIs overview,” just like before, and on the left-hand side menu, click on credentials.

Credentials

Then click on “Create Credentials” and create a “Service Account.”

TTS-STT - Service Account

Enter any service account name you like, and click Create. Optional, you can grant service account access to the project and click Done.

Grant Access

Now click on the service account you just created. The last click will take you to the service account details.

service account details

Go to the “Keys” section and click on “Add Key” and “Create New Key,” which will create a new key. This key is associated with your application through the service account.

Add Key

Select JSON and click on Create in the pop-up, which will download a JSON file containing the key to your machine. Please note where you save this file since you will need it next.

Json File

Step 4) Installing the container0

docker-compose from hub

version: "3.7"
services:
  tts-stt:
    image: techblog/tts-stt:latest
    ports:
      - "8080:8080"
    container_name: tts-stt
    labels:
      - "com.ouroboros.enable=true"
    networks:
      - default
    volumes:
      - ./ttstt/keys/key-file.json:/opt/ttstt/keys/key-file.json
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

“key-file.json” name is mandatory (you can’t change it). This is the key file you have created and downloaded in step 3.

Now, run docker-copmose up -d to pull and run your container. Open your browser and navigate to your container IP address with port 8080. You should see the following screen. 

TTS-STT UI

Be the first to comment

Leave a Reply

Your email address will not be published.


*