Skip to content

icoxfog417/pyoxford

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyoxford

Simple Python Client for Microsoft Cognitive Services.

Installation

pip install pyoxford

And you have to prepare Cognitive Service account to use each services.

Speech APIs

import pyoxford

text = "welcome to microsoft oxford speech api"
api = pyoxford.speech("your_client_id", "your_client_secret")

# text to speech (.wav file)
binary = api.text_to_speech(text)
with open("voice.wav", "wb") as f:
    f.write(binary)

# speech to text
recognized = api.speech_to_text("voice.wav")

if text == recognized:
    print("success!!")

see also official document.

Vision APIs

Analyze

import pyoxford

api = pyoxford.vision("your_primary_key")
result = api.analyze("https://oxfordportal.blob.core.windows.net/vision/Analysis/4.jpg")

for c in result.categories:
    print(c.name)

see also official document.

OCR

import pyoxford

api = pyoxford.vision("your_primary_key")
result = api.ocr("https://oxfordportal.blob.core.windows.net/vision/OpticalCharacterRecognition/1.jpg")

doc = result.to_document()
for par in doc:
    print("\n".join(par))

see also official document.

Translator API

Translator API is not project oxford's api, but it is very useful to use with speech api and so on. To use this API, you have to do step1 & step2 of Get started.

import pyoxford

api = pyoxford.translator("your_client_id", "your_client_secret")
result = api.translate("My name is John.", "ja")

if "私の名前はジョンです。" == result:
    print("Well translated!!")

About

Python Client for Microsoft Project Oxford

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages