DEV Community

Abraham Jerry Kakooza
Abraham Jerry Kakooza

Posted on

Deploying an English Speech to Text model to heroku

I will be showing you how to deploy the coqui-ai english speech to text model on heroku such that you can use it within your applications.

The model we will deploy can be found here . It is a large vocab English speech to text model.

First within your terminal, clone this repository as shown below and navigate into the en-stt-engine directory

git clone https://github.com/KakoozaJerry/en-stt-engine.git
cd en-stt-engine
Enter fullscreen mode Exit fullscreen mode

Make sure you have git lfs installed on your machine, you can find instructions here.

Run the command below after installing git lfs

git lfs install
Enter fullscreen mode Exit fullscreen mode

It should return something like what is below

Updated git hooks.
Git LFS initialized.
Enter fullscreen mode Exit fullscreen mode

Open your heroku in the browser and type the link below

https://dashboard.heroku.com/new-app

Incase you are not logged in you will be prompted to do so.
Your webpage should return the view below, where you can input the name you want for the app, I use english-stt

Image description

Now you can go back to your terminal and run

heroku login
Enter fullscreen mode Exit fullscreen mode

You will see the log below

heroku: Press any key to open up the browser to login or q to exit: 
Enter fullscreen mode Exit fullscreen mode

Press any key as stated and click the login button shown in the browser, if successful this will show.

Opening browser to https://cli-auth.heroku.com/auth/cli/browser/......
Logging in... done
Logged in as user@gmail.com
Enter fullscreen mode Exit fullscreen mode

Set the name of the remote origin from heroku app you created above using the command below

heroku git:remote -a <stt-app-name>
Enter fullscreen mode Exit fullscreen mode

This should return

set git remote heroku to https://git.heroku.com/<stt-app-name>.git
Enter fullscreen mode Exit fullscreen mode

Specify the heroku python as your build pack as shown below in your terminal

heroku buildpacks:set heroku/python
Enter fullscreen mode Exit fullscreen mode

This is what it should return

Buildpack set. Next release on english-stt will use heroku/python.
Run git push heroku main to create a new release using this buildpack.
Enter fullscreen mode Exit fullscreen mode

Add the ffmpeg buildpack since this will also be needed

heroku buildpacks:add https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
Enter fullscreen mode Exit fullscreen mode

Below is what it should return

Buildpack added. Next release on english-stt will use:
  1. heroku/python
  2. https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
Run git push heroku main to create a new release using these buildpacks.
Enter fullscreen mode Exit fullscreen mode

Add git-lfs buildpack using the command below

heroku buildpacks:add https://github.com/raxod502/heroku-buildpack-git-lfs
Enter fullscreen mode Exit fullscreen mode

This is what will be returned

Buildpack added. Next release on english-stt will use:
  1. heroku/python
  2. https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
  3. https://github.com/raxod502/heroku-buildpack-git-lfs
Run git push heroku main to create a new release using these buildpacks.
Enter fullscreen mode Exit fullscreen mode

Set your HEROKU_BUILDPACK_GIT_LFS_REPO variable to point to the github repository as shown below

heroku config:set HEROKU_BUILDPACK_GIT_LFS_REPO=https://github.com/KakoozaJerry/en-stt-engine.git
Enter fullscreen mode Exit fullscreen mode

This is what will be returned

Setting HEROKU_BUILDPACK_GIT_LFS_REPO and restarting ⬢ english-stt... done, v6
 ▸    Warning: The "HEROKU_" namespace is protected and shouldn't be used.
Enter fullscreen mode Exit fullscreen mode

You should be able to publish your app using this command

git push heroku main:master --no-verify
Enter fullscreen mode Exit fullscreen mode

This will take a while depending on the speed of your internet

After a successful deployment, you should see successful deployment and you can test out your stt api in postman as shown below

Image description

You can test it out with this audio and a key value of file.

Make sure to select form data as shown in the screenshot above.

Discussion (2)

Collapse
deborahtrez profile image
Aanyu Deborah Oduman

Very nice

Collapse
marcomoscatelli profile image
Marco Moscatelli

Good tutorial mate thank you!