txn_id = "replace this with your Transaction ID"
auth_token = "Bearer <API TOKEN>"
processing_state_url = "https://api.marsview.ai/cb/v1/conversation/get_txn/{txn_id}"
metadata_url = "https://api.marsview.aicb/v1/conversation/fetch_metadata/{txnId}"
def get_speech_to_text_state():
'authorization': '{}'.format(auth_token)
response = requests.request("GET", processing_state_url.format(txn_id=user_id), headers=headers, json=payload)
if response.status_code == 200 and response.json()["status"] == "true":
return response.json()["data"]["enableModels"]["state"]["status"]
raise Exception("Custom exception")
def get_speech_to_text_metadata():
'authorization': '{}'.format(auth_token)
response = requests.request("GET", metadata_url.format(txn_id=user_id), headers=headers, json=payload)
if response.status_code == 200 and response.json()["status"] == "true":
return response.json()["data"]["transcript"]
raise Exception("Custom exception")
state = get_speech_to_text_state()
return get_speech_to_text_metadata()
elif state == "uploaded":
raise Exception("An error has occured during the processing of this request")
if __name__ == "__main__":