Skip to content

Speech to Text Local

This page describes how to run Speech to Text on your local system using Docker or Podman.

The product documentation will provide more details and additional capabilities not shown in this example.

Access to images

To run this example you need to have access to the IBM Watson Libraries for Embed container images. These are available on the IBM Container Registry, but you need an entitlement key

For the code in this repo I use a local mirror, hosted in a Project Quay repository.

If you are running against the IBM registry then you will need to change the images from lab-registry-quay-openshift-operators.apps.ocp.lab.home/watson-libs to cp.icr.io/cp/ai and login to the repository before trying to access any images with

docker login cp.icr.io --username cp --password <entitlement_key>
podman login cp.icr.io --username cp --password <entitlement_key>

Building the runtime

To create a usable speech to text runtime container, the standard runtime needs to be combined with appropriate model(s). There are a number of standard models provided. In addition to the model(s) a configuration needs to be provided. This configuration needs to be customised to match the included model(s).

The files used in this example can be found here.

To build the container image run the command:

docker build -f Containerfile . -t stt-standalone
podman build --tls-verify=false -f Containerfile . -t stt-standalone

You should store the container image in a repository if you want to use it on a Kubernetes platform or make it available to other developers to run locally

docker tag stt-standalone lab-registry-quay-openshift-operators.apps.ocp.lab.home/brian/stt-standalone:0.0.1
docker push lab-registry-quay-openshift-operators.apps.ocp.lab.home/brian/stt-standalone:0.0.1
podman tag stt-standalone lab-registry-quay-openshift-operators.apps.ocp.lab.home/brian/stt-standalone:0.0.1
podman push --tls-verify=false lab-registry-quay-openshift-operators.apps.ocp.lab.home/brian/stt-standalone:0.0.1

Running the container

The container can be run on your local system. The following commands assume you have the tool on your local system (either built or pulled from a repository)

docker run --rm -it --env ACCEPT_LICENSE=true --publish 1080:1080 stt-standalone
podman run --rm -it --env ACCEPT_LICENSE=true --publish 1080:1080 stt-standalone

Submitting requests to the container

To submit a request to the container you need an audio file. There is one in the repository, test.wav.

This was created on a MacOS system using the standard Voice Memos app. Once a recording was made, select it in the All Recordings list, copy it (⌘C) then paste it to the Desktop. Use the Convertio site, or similar, to convert the m4a file to a wav file.

Todo

Work out process to create audio file on Linux and Windows systems

To test the speech to text container the curl utility can be used to submit requests:

curl "http://localhost:1080/speech-to-text/api/v1/recognize" --header "Content-Type: audio/wav" --data-binary @test.wav

Refer to the API reference for details of the requests that can be made