Skip to content

Instantly share code, notes, and snippets.

@tylernappy
Last active April 10, 2017 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylernappy/14d5215823c17f3a6dc52ba1677b9f75 to your computer and use it in GitHub Desktop.
Save tylernappy/14d5215823c17f3a6dc52ba1677b9f75 to your computer and use it in GitHub Desktop.
# install the official Haven OnDemand Python wrapper: https://github.com/HPE-Haven-OnDemand/havenondemand-python
# pip install havenondemand
from havenondemand.hodclient import *
client = HODClient("APIKEY", "v1")
# params = {'file': 'path/to/file.mp3'} # if using a local file
params = {'url': 'https://www.havenondemand.com/sample-content/videos/hpnext.mp4'} # if using a publicly facing URL
response_async = client.post_request(params, HODApps.RECOGNIZE_SPEECH, async=True)
jobID = response_async['jobID']
def getJobAsyncJobStatus(jobID):
print 'Processing...'
response = client.get_job_status(jobID)
if response == None: # still transcribing...
getJobAsyncJobStatus(jobID)
else: # done trasncribing
transcription = response['document'][0]['content']
print transcription
getJobAsyncJobStatus(jobID)
@SaidBadar
Copy link

SaidBadar commented Apr 5, 2017

hello tylernappy, i tried to run your code and i got an error message as follows:

Processing...
Traceback (most recent call last):
File "C:\Users\zain\AppData\Local\Programs\Python\Python36-32\videoTranscriptTest1.py", line 21, in <module> getJobAsyncJobStatus(jobID)
File "C:\Users\zain\AppData\Local\Programs\Python\Python36-32\videoTranscriptTest1.py", line 18, in getJobAsyncJobStatus transcription = response['document'][0]['content']
KeyError: 'document'

i have no idea what is wrong here, could you help out on this matter? thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment