watson

package module
v0.0.0-...-57c1329 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2016 License: MIT Imports: 1 Imported by: 0

README

Golang library to use the Watson Developer Cloud services, a collection of REST APIs and SDKs that use cognitive computing to solve complex problems.

Table of Contents

Preamble

The ultimate target of this library is to support all of IBM's Watson APIs. However at the current time we only support access to the following endpoints:

  • Speech-To-Text (without streaming support)

I'll try to add more functions in the future. Your patience is highly appreciated. If you can't wait for a specific function, feel free to help me out and contribute!

Also, most of the parameter documentation for the currently supported APIs was not written by me, but by the brave men and woman of the IBM developer team. All credit for excellent documentation goes to them and I'm not going to take that away from them.

Installation

$ go get github.com/maxl28/watson-developer-cloud

Usage

Acquire your credentials via IBM's Bluemix service and put them in a config file of your choice. You'll need them to initialize the Watson client like this:

import "github.com/maxl28/watson-developer-cloud/watson"

w := watson.New(watson.WatsonOptions{
		Username: "YOUR_USERNAME",
		Password: "YOUR_PASSWORD",
	})

IBM Watson Services

Speech to Text

Assuming that you've already created your Watson client, you may now initialize the Speech-To-Text client like this:

import "github.com/maxl28/watson-developer-cloud/speech-to-text"

stt := speech_to_text.New(w, speech_to_text.SpeechToTextOptions{})

Now, we'll make a request to the recognize endpoint with minimal parameters:

file, _ := os.Open("YOUR_TEST_FILE.ogg")

defer file.Close()

data, _ := stt.Recognize(speech_to_text.RecognizeParameters{
	Audio: file,
	Content_type: "audio/ogg;codecs=opus",
	Model: "en-US_BroadbandModel",
	Max_alternatives: 3,
})

result, _ := ioutil.ReadAll(data.Body)

Contributing

Feel free to help me expand this little library and help the Go community use IBM's awesome API services.

License

This library is licensed under the MIT license. Full license text is available in LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watson

type Watson struct {
	Options WatsonOptions
}

ToDo: Write documentation

func New

func New(options WatsonOptions) Watson

ToDo: Write documentation

func (*Watson) SignRequest

func (w *Watson) SignRequest(req *http.Request) *http.Request

Sign a HTTP request with our Watson credentials. Either basic HTTP Auth with username and password or an API key.

type WatsonOptions

type WatsonOptions struct {
	// Shall we authenticate or not?
	Use_unauthenticated bool
	// Credentials used for authentication, assuming that we even use authentication.
	Username, Password, Api_key string
	// Which version of the API should be used.
	Version string
	// Determines the Watson service endpoint we're using.
	// Not yet implemented
	Alchemy string
	// Not yet implemented
	Use_vcap_services bool
}

ToDo: Write documentation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL