Golang SDK for TUPU visual recognition service (v1.6.1)
- add speech stream SDK and example
- add video(async/sync) sdk and adjust speech async sdk
- add testSync method and lib
- image remove limited and memory optimization
- image api with function options
- add task param to image recognition
- refactor speech sdk
- add speech method and lib
- fix returning data when it's not JSON data
- fix to return failure response status code
- support setting http client
- removed log.Fatal
- fixed bug in parsing result
- add shortcut methods for URL or path
- 1st ready version
go get github.com/tuputech/tupu-go-sdk/recognition
- Image recognition interface example
- shortSpeech recognition interface example
- longSpeech recognition interface example
import "github.com/tuputech/recognition"
func (h *Handler) PerformWithURL(secretID string, imageURLs []string, tags []string) (result string, statusCode int, e error)
PerformWithURL return a json string
and a int
express response, a error
identifying success of failure
It is useful for the recognition function using remote image
Params Descrition
- secretId: secret-id for recognition tasks
- imageURLs: array of image URLs
- tags: array of tags for images (optional)
func (h *Handler) PerformWithPath(secretID string, imagePaths []string, tags []string) (result string, statusCode int, e error)
PerformWithPath return a json string
and a int
express response, a error
identifying success of failure
It is useful for the recognition function using local image
Params Descrition
- secretId: secret-id for recognition tasks
- imagePaths: array of image paths
- tags: array of tags for images (optional)
func (h *Handler) Perform(secretID string, images []*Image, tags []string) (result string, statusCode int, e error)
Perform return a json string
and a int
express response, a error
identifying success of failure
Construct the data structures we provide to execute reccognition
There are three functions you can use to construct an Image
object:
func NewRemoteImage(url string) *Image
func NewLocalImage(path string) *Image
func NewBinaryImage(buf []byte, filename string) *Image
Params Descrition
- secretId: secret-id for recognition tasks
- images: array of Image struct, but don't mix use of URL and path/binary in one call
- tags: array of tags for images (optional)
Contains
Package speechsync
andPackage speechasync
import "github.com/tuputech/recognition/speech/speechsync"
func (syncHdler *SyncHandler) PerformWithBinary(secretID string, binaryData map[string][]byte) (result string, statusCode int, err error)
PerformWithBinary return a json string
and a int
express response, a error
identifying success of failure
Identification with binaries is valid, but binaries need to be built with the Map type for filetype supported only in amr, mp3, wmv, wav, flv
format
Params Descrition
- secretID: secret-id for recognition task
- binaryData: map type, key means file name, value means binary data
func (syncHdler *SyncHandler) PerformWithPath(secretID string, speechPaths []string) (result string, statusCode int, err error)
PerformWithPath return a json string
and a int
express response, a error
identifying success of failure
It is useful for the recognition function using local speech file
Params Descrition
- secretID: secret-id for recognition task
- speechPaths: local speech paths
func (syncHdler *SyncHandler) PerformWithURL(secretID string, URLs []string) (result string, statusCode int, err error)
PerformWithURL return a json string
and a int
express response, a error
identifying success of failure
It is useful for the recognition function using remote speech file
Params Descrition
- secretID: secret-id for recognition task
- URLs: remote speech address
import "github.com/tuputech/recognition/speech/speechasync"
func (asyncHdler *AsyncHandler) Perform(secretID string, speechAsync *SpeechAsync) (result string, statusCode int, err error)
Perform return a json string
and a int
express response, a error
identifying success of failure
Params Descrition
- secretID: secret-id for recognition task
- speechAsync: SpeechAsync struct wrapper async speech message for request
Only remote files are supported, and request information is created via structure SpeechAsync
// SpeechAsync is a structure that encapsulates async speech messages
type SpeechAsync struct {
// FileRemoteURL represents the address of the big voice, can't be empty
FileRemoteURL string
// CallbackUrl represents the address of the callback result, cant' be empty
CallbackURL string
// CallbackRule represents the Rule of the callback, empty is using default rule, `all` is callback all result
CallbackRule string
// RoomID represents the room id
RoomID string
// UserID represents the user id
UserID string
// ForumID represents the forum id
ForumID string
}