Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(1) | Call(1) | Derive(0) | Import(0)
def func(filename): audio = open(filename, 'rb') filesize = os.path.getsize(filename) print filename,"Read","\n" req = urllib2.Request(url='https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US') req.add_header('Content-type','audio/x-flac; rate=16000') req.add_header('Content-length', str(filesize)) req.add_data(audio) print "Request built","\n" response = urllib2.urlopen(req) print "Response returned","\n" return response.read()
s.call(["flac","output.wav","-f"]) #This simply changes the file to a .flac to be used by the google speech api response = win.func('output.flac') #Voila this returns my important response! alphabets = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']