Sign inSign up

alessio21/text-to-speech

By alessio21

•Updated over 2 years ago

Image
0

234

alessio21/text-to-speech repository overview

⁠TEXT-TO-SPEECH with SpeechT5 model

This image runs the SpeechT5 model for text-to-speech task.

⁠How it works

This image exposes a POST API that you can use to send your text and it will be converted into a numpy array representing the corresponing audio. Once the array is generated, in order to "listen" it, it must be sent to a service capable of producing audio from the array: you can use this⁠ docker image (see instructions).

Container exposed port: 1000

Endpoint url: "/tts"

⁠How to run

Choose a folder to put in:

  • a speaker embedding vector. You can find some speaker embedding vectors here⁠. In this example we will use the "slt.npy" vector so download and put it into a sub-folder called "speaker_embedding".
  • an empty folder called "tts_models". Once the container is launched, you will find the SpeechT5 models here.
  • a docker-compose.yml file.

Below is an example of docker-compose.yml file: it starts a multi-container application capable of generating audio from a written text:

version: '3'

networks:
  text-to-speech:
    driver: bridge

services:

  container_audio:
    image: alessio21/play-numpy-array
    ports:
     - "2865:2865"
    networks:
      - text-to-speech

  container_tts:
    image: alessio21/text-to-speech
    ports:
     - "1000:1000"
    volumes:
     - ./tts_models:/app/models
     - ./speaker_embedding:/app/speaker_embedding
    environment:
      - SPEAKER=slt
      - API_URL=http://container_audio:2865/send_array
    networks:
      - text-to-speech

Send your text to be converted in audio:

import requests

API_URL = "http://localhost:1000/tts"

prompt = "Hi! Who are you? I am your AI assistant"
payload = {"text":prompt}

resp = requests.post(API_URL, json=payload)
response  resp.json()
print(response)

⁠Usage example

In this repository⁠ the image is used to generate audio for a voice chatbot (see the docker-compose.yml file).

Tag summary

Content type

Image

Digest

sha256:464aa2986…

Size

544.6 MB

Last updated

over 2 years ago

docker pull alessio21/text-to-speech