#!/usr/bin/python # Copyright 2012 Nexiwave Canada. All rights reserved. # Nexiwave Canada PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. import sys, os, json, urllib2, urllib, time # You will need python-requests package. It makes things much easier. import requests if len(sys.argv) != 4: sys.stderr.write("Usage: " + sys.argv[0] + " \n") sys.exit(1) # Login details: USERNAME = sys.argv[1] PASSWORD = sys.argv[2] def transcribe_audio_file(filename): """Transcribe an audio file using Nexiwave""" url = 'https://api.nexiwave.com/SpeechIndexing/file/storage/' + USERNAME +'/recording/?authData.passwd=' + PASSWORD + '&auto-redirect=true&response=application/raw-transcript' # To receive transcript in plain text, instead of html format, comment this line out (for SMS, for example) url = url + '&transcriptFormat=html' # Ready to send: # sys.stderr.write("Send audio for transcript with " + url + "\n") r = requests.post(url, files={'mediaFileData': open(filename,'rb')}) # Perform your magic here: print(r.content) if __name__ == '__main__': transcribe_audio_file(sys.argv[3])