Simple Python Client for Microsoft Cognitive Services.
pip install pyoxford
And you have to prepare Cognitive Service account to use each services.
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.
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.
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 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!!")