Tutorial
Deploy customizable text-to-speech functions on Red Hat OpenShift
Walk through the steps to install a customizable text-to-speech service in Red Hat OpenShiftArchive date: 2024-05-29
This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.IBM Watson Text to Speech enables you to convert written text into natural-sounding audio in various languages and voices within an existing application or within IBM watsonx Assistant.
This tutorial walks you through the steps to install a customizable Text to Speech Service in Red Hat OpenShift. The tutorial uses this Helm Chart to deploy the service. You can use any classic Kubernetes cluster to deploy this text-to-speech Helm Chart.
Reference architecture

Prerequisites
To follow this tutorial, you must:
- Install Helm 3.
- Ensure that you have an entitlement key. You might need to create one. This key is required to access the images used in this tutorial.
Set an environment variable.
export IBM_ENTITLEMENT_KEY=<Set the entitlement key>Have S3-compatible storage. This tutorial includes instructions on setting this up in IBM Cloud. For other cloud platforms, use the instructions from the cloud provider.
- Have a PostgreSQL database, which is required to manage metadata that is related to customization.
- Have a Red Hat OpenShift Cluster on which you deploy the service.
S3-compatible storage
For customization, you need an S3-compatible storage service that supports HMAC (access key and secret key) credentials. Watson Speech requires a bucket that it can read and write to. The bucket is populated with stock models at installation and also stores customization artifacts, including training data and trained models.
Steps
Step 1. Create an S3 bucket on IBM Cloud
The following steps explain how to obtain IBM Cloud S3 bucket HMAC credentials and endpoint. If you are using a different cloud, then use the instructions that are given by the cloud provider to set it up.
- Log in to IBM Cloud.
- From the IBM Cloud dashboard, click the Cloud Object Storage service instance that you want to work with.
- To get the Bucket name, click Buckets in the left pane, and select your preferred bucket name and make a note of it.
- To get the endpoint URLs, click Endpoint in the left pane, and select your preferred location or region.
- Copy your preferred public
endpoint(for example, s3.us-east.cloud-object-storage.appdomain.cloud), and use it as the value for theEndpoint URLfield (orendpointUrlparameter). - Copy your preferred location or
region(for example, us-east), and use it as the value for theRegionfield (orregionparameter).
- Copy your preferred public
- To view the service credentials, click Service credentials in the left pane, and then click View credentials. (If you want to define new credentials, click New credential, click Advanced options, then select Include HMAC Credential.)
- Copy the
cos_hmac_keys/secret_access_keyvalue, and use it as the value for theSecret access keyfield (orsecretAccessKey parameter). - Copy the
cos_hmac_keys/access_key_idvalue, and use it as the value for theAccess key IDfield (oraccessKeyId parameter).
Step 2. Set S3 information in environment variables
Set the S3 crededentials and information in the following environment variables. These variables are used when deploying the Text to Speech Helm Chart.
export S3_BUCKET_NAME=<Bucket name you found in step 3 >
export S3_ENPOINT_URL=<Endpoint URL you found in step 4.1>
export S3_REGION=<Region can be found in step 4.2 when you select your bucket>
export S3_SECRET_KEY=<secretAccessKey you found in step 6>
export S3_ACCESS_KEY=<accessKeyId you found in step 7>
The commands that you use to set the variables should look similar to the following example.
export S3_BUCKET_NAME=speech-embed
export S3_REGION=us-east
export S3_ENPOINT_URL=https://s3.us-east.cloud-object-storage.appdomain.cloud
export S3_SECRET_KEY=12a3bcd4567890ef123g4567890hij12k1m3n4567o8901p2
export S3_ACCESS_KEY=1a2dfbc3d45678901ef2g3h45678i90jkl
Step 3. Set PostgreSQL information in environment variables
A PostgreSQL database is required to manage metadata that is related to customization. The customization container uses TLS to Postgres, but always sets up the connection with a NonValidatingFactory, which does not do certificate validation.
Set the database connection information in the following environment variables. These variables are used when deploying the Text to Speech Service Helm Chart.
export POSTGRES_HOST=<Postgresql hostname>
export POSTGRES_USER=<Postgresql username>
export POSTGRES_PASSWORD=<Postgresql password>
Step 4. Install Text to Speech Helm Chart
Clone the Helm Chart GitHub repository.
git clone https://github.com/IBM/ibm-watson-embed-charts.git
cd ibm-watson-embed-charts/charts
The containers that are deployed by this chart come from the IBM Entitled Registry. You must create a Secret with credentials to pull from this registry. The default name is ibm-entitlement-key, but this can be changed by updating the value of imagePullSecrets.
The following code shows an example command to create the pull secret.
oc create secret docker-registry ibm-entitlement-key \
--docker-server=cp.icr.io \
--docker-username=cp \
--docker-password=$IBM_ENTITLEMENT_KEY \
--docker-email=<your-email>
By default, the en-US_MichaelV3Voice and en-US_AllisonV3Voice models are enabled, with defaultModel set to en-US_AllisonV3Voice.
Helm Charts have configurable values that can be set at installation. To configure the values (for example, enabling additional models), refer to the base values.yaml file for documentation and value defaults. Values can be changed by using the --set parameter or by using YAML files that are specified with -f/--values. In the following example, I set values by using the --set parameter.
helm install tts-release ./ibm-watson-tts-embed \
--set license=true \
--set nameOverride=tts \
--set models.enUSTelephony.enabled=false \
--set postgres.host=${POSTGRES_HOST} \
--set postgres.user=${POSTGRES_USER} \
--set postgres.password=${POSTGRES_PASSWORD} \
--set objectStorage.endpoint=${S3_ENPOINT_URL} \
--set objectStorage.region=${S3_REGION} \
--set objectStorage.bucket=${S3_BUCKET_NAME} \
--set objectStorage.accessKey=${S3_ACCESS_KEY} \
--set objectStorage.secretKey=${S3_SECRET_KEY}
Step 5. Verify the chart
For chart verification, see the instructions (from the NOTES.txt file within the chart) after the Helm installation completes. The instructions also can be viewed by running the following command.
helm status tts-release
For basic usage of customization, see the documentation.
You can also look at the complete API reference for the Watson Text to Speech Service.
Step 6. Test the service
In one terminal, create a proxy through the service.
oc proxyIn another terminal, view the list of voices.
curl --url "http://localhost:8001/api/v1/namespaces/stt-demo/services/https:tts-release-runtime:https/proxy/text-to-speech/api/v1/voices"Send a
/synthesizerequest to generate speech, and write the output.wav file.curl --url "http://localhost:8001/api/v1/namespaces/stt-demo/services/https:tts-release-runtime:https/proxy/text-to-speech/api/v1/recognize?model=en-US_AllisonV3Voice" \ --header "Content-Type: application/json" \ --data '{"text":"Hello world"}' \ --header "Accept: audio/wav" \ --output output.wav
Step 7. Uninstall the chart
To uninstall and delete the Text to Speech deployment, run the following command.
helm delete tts-release
Summary
In this tutorial, you learned how to install a customizable Text to Speech Service in Red Hat OpenShift.