Show Menu
Cheatography

IBM Watson Cheat Sheet (DRAFT) by

IBM Watson application

This is a draft cheat sheet. It is a work in progress and is not finished yet.

IBM Watson Website

Link
Create Ressource
AI -> Visual Recogn­ition
make service
Lite Plan
get important inform­ation
API Key and URL

Instal­lation

Install opencv
pip install opencv­-python
Install ibm-watson
pip install ibm-watson

Test Applic­ation

Send Picture to Goolge press
d
Quit applic­ation press
q
 

Paste in a Pythonfile

import cv2
from ibm_watson import VisualRecognitionV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
import json
import sys
 
authenticator = IAMAuthenticator('API KEY')
service = VisualRecognitionV3(
    version='2020-02-26',
    authenticator=authenticator
)
service.set_service_url('URL')
 
cap = cv2.VideoCapture(0)
 
key = ''
while( key != 'q' ):
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
intkey = cv2.waitKey(2)
    if( intkey > 0 ):
        key = chr(intkey)
    else:
        key = ''
 
    if key == 'd' :
        cv2.imwrite('upload.jpg', frame)
        with open('upload.jpg','rb') as file:
            classes = service.classify(images_file=file,threshold='0.6').get_result()
            print(json.dumps(classes, indent=2))

Speech to Text

curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: audio/flac" \
--data-binary @{path_to_file}audio-file.flac \
"{url}/v1/recognize?timestamps=true&max_alternatives=3"
 

Speech to Text

install
curl

Speech to Text

{
  "results": [
    {
      "alternatives": [
        {
          "timestamps": [
            ["several":, 1.0, 1.51],
            ["tornadoes":, 1.51, 2.15],
            ["touch":, 2.15, 2.5],
            . . .
          ]
        },
        {
          "confidence": 0.96
          "transcript": "several tornadoes touch down as a line
of severe thunderstorms swept through Colorado on Sunday "
        },
        {
          "transcript": "several tornadoes touched down as a line of
severe thunderstorms swept through Colorado on Sunday "
        },
        {
          "transcript": "several tornadoes touch down as a line
of severe thunderstorms swept through Colorado and Sunday "
        }
      ],
      "final": true
    }
  ],
  "result_index": 0
}