Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Latest commit

 

History

History
108 lines (79 loc) · 3.83 KB

File metadata and controls

108 lines (79 loc) · 3.83 KB

Run locally

This document shows how to run the application on your local machine.

Steps

  1. Clone the repo
  2. Configure credentials
  3. Start the server

Clone the repo

Clone the repo locally. In a terminal, run:

git clone https://github.com/IBM/text-to-speech-code-pattern
cd text-to-speech-code-pattern

Configure credentials

Copy the .env.example file to .env.

cp .env.example .env

Edit the .env file to configure credentials before starting the Node.js server. The credentials to configure will depend on whether you are provisioning services using IBM Cloud Pak for Data or on IBM Cloud.

Click to expand one:

IBM Cloud Pak for Data

For the Text to Speech service, the following settings are needed:

  • Set TEXT_TO_SPEECH_AUTH_TYPE to cp4d
  • Provide the TEXT_TO_SPEECH_URL, TEXT_TO_SPEECH_USERNAME and TEXT_TO_SPEECH_PASSWORD collected in the previous step.
  • For the TEXT_TO_SPEECH_AUTH_URL use the base fragment of your URL including the host and port. I.e. https://{cpd_cluster_host}{:port}.
  • If your CPD installation is using a self-signed certificate, you need to disable SSL verification with both TEXT_TO_SPEECH_DISABLE_SSL and TEXT_TO_SPEECH_AUTH_DISABLE_SSL set to true. You might also need to use browser-specific steps to ignore certificate errors (try browsing to the AUTH_URL). Disable SSL only if absolutely necessary, and take steps to enable SSL as soon as possible.
  • Make sure the examples for IBM Cloud and bearer token auth are commented out (or removed).
#----------------------------------------------------------
# IBM Cloud Pak for Data (username and password)
#
# If your services are running on IBM Cloud Pak for Data,
# uncomment and configure these.
# Remove or comment out the IBM Cloud section.
#----------------------------------------------------------

TEXT_TO_SPEECH_AUTH_TYPE=cp4d
TEXT_TO_SPEECH_URL=https://{cpd_cluster_host}{:port}/text-to-speech/{release}/instances/{instance_id}/api
TEXT_TO_SPEECH_AUTH_URL=https://{cpd_cluster_host}{:port}
TEXT_TO_SPEECH_USERNAME=<add_text-to-speech_username>
TEXT_TO_SPEECH_PASSWORD=<add_text-to-speech_password>
# # If you use a self-signed certificate, you need to disable SSL verification.
# # This is not secure and not recommended.
# TEXT_TO_SPEECH_DISABLE_SSL=true
# TEXT_TO_SPEECH_AUTH_DISABLE_SSL=true

IBM Cloud

For the Text to Speech service, the following settings are needed:

  • Set TEXT_TO_SPEECH_AUTH_TYPE to iam
  • Provide the TEXT_TO_SPEECH_URL and TEXT_TO_SPEECH_APIKEY collected in the previous step.
  • Make sure the examples for IBM Cloud Pak for Data and bearer token auth are commented out (or removed).

# Copy this file to .env and replace the credentials with
# your own before starting the app.

#----------------------------------------------------------
# IBM Cloud
#
# If your services are running on IBM Cloud,
# uncomment and configure these.
# Remove or comment out the IBM Cloud Pak for Data sections.
#----------------------------------------------------------

TEXT_TO_SPEECH_AUTH_TYPE=iam
TEXT_TO_SPEECH_APIKEY=<add_text-to-speech_apikey>
TEXT_TO_SPEECH_URL=<add_text-to-speech_url>

Need more information? See the authentication wiki.

Start the server

npm install
npm start

The application will be available in your browser at http://localhost:5000. Return to the README.md for instructions on how to use the app.

return