Create A Model
With IBM STT the whole process can be managed via CURL commands. There are other ways also to interface with the STT environment.
To create a language model with a customization id, run this curl command.
The apikey and url are displayed when you create the service in the IBM Cloud console.
curl -X POST -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx"
--header "Content-Type: application/json"
--data "
{"name": "Mobile Networks",
"base_model_name": "en-US_BroadbandModel",
"description": "This is a custom language model for Mobile Networks"}"
"https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations"
The customization ID is returned. Save this value, as it will be used as a reference going forward.
{"customization_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx"}
List Customization Models
If you have multiple models, you can list them and view the meta data.
curl -X GET -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations"
With each model shown as:
Upload Corpus File
Make sure you are in the directory where your corpus text file is located, and run this command. The customization ID is added to the URL as the reference.
curl -X POST -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" — data-binary @MobileNetworksCorpus.txt "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/corpora/mobile"
View The Status
Once the corpus file is uploaded, you can view the status of your upload:
curl -X GET -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/corpora/mobile"
Again the customization ID we gleaned earlier in the story is part of the URL, marked by x’s.
Training The Language Model
The language model can now be trained and the out-of-vocabulary words will be added.
curl -X POST -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/train"
View Training Results
The training results can be viewed…
curl -X GET -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/words?sort=%2Balphabetical"
And below you can see result from the training.
Adding Individual Words
A JSON file can be defined within the CURL command and data can be added to the language model in this way, without making use of a corpus file. With this option a word can be added, with tags for:
- Sounds Like (multiple options can be added)
- Display as
curl -X POST -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx"
--header "Content-Type: application/json"
--data
"{"words":
[ {"word": "PUK",
"sounds_like":
[ "phuk", "puck", "pike"],
"display_as": "PUK"},
{"word": "iPhone",
"sounds_like": ["I. phone"]} ]}" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/corpora/mobile"
Using the same command as previously used, the result can be viewed:
curl -X GET -u "apikey:xxxxxxxxxxxxxxxxxxxxxxxxxx" "https://api.eu-gb.speech-to-text.watson.cloud.ibm.com/instances/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/v1/customizations/xxxxxxxxxxxxxxxxxxxxxxxx/words?sort=%2Balphabetical"