def speechRecognition(lang, min_value, max_value, sleep_time): recognizer = speech_recognition.Recognizer() with speech_recognition.Microphone() as source: #print("Listening...") audio = recognizer.listen(source) words = "" try: ban = 1 if lang is ban: words = recognizer.recognize_google(audio, language="bn-BD") else: words = recognizer.recognize_google(audio) matches = re.search("Hey bot search for me (.*)", words) googleSearch.googleSearch(words, matches, min_value, max_value, sleep_time) except: errors.append( 'Voice search assistant could not recognize your speech, try again.' ) errors.append(" ") errors.append("Turn ON, to search your queries.") errors.append(" ") print('Done from speechRecognition')
def handle_parsed(prefix, command, params): if command == 'PRIVMSG': if(params[0] == CHANNEL and params[1].startswith('!g') and not params[1].startswith('!geo')): searchTerm = params[1][3:] conn.send_string( 'PRIVMSG {0} :'.format(CHANNEL) + googleSearch(searchTerm) ) if params[0] == CHANNEL and params[1].startswith('!geo'): searchTerm = params[1][5:] conn.send_string( 'PRIVMSG {0} :'.format(CHANNEL) + geoLocate(searchTerm) ) if params[0] == CHANNEL and params[1].startswith('!imdb'): searchTerm = params[1][6:] conn.send_string( 'PRIVMSG {0} :'.format(CHANNEL) + imdbSearch(searchTerm) ) if params[0] == CHANNEL and params[1].startswith('!w'): searchTerm = params[1][3:] conn.send_string( 'PRIVMSG {0} :'.format(CHANNEL) + weatherLookup(searchTerm) )
def upload(): if request.method == 'POST' and 'files' in request.files: filename = documents.save(request.files['files']) output = googleSearch('tmp/uploads/' + filename) return render_template('output.html', output=output) else: return render_template('index.html')
def query_results(): if request.method == "POST": ques = request.form.get("query") session['news'] = ques session['feature'] = 'questions' x = query(ques) y = googleSearch(ques) if ques == '': return render_template("questions.html", error="Input cannot be empty") if x == 'error none found': return render_template("query-results.html", q=ques, o='', a='Sorry, no results were found.', useful_results=y) return render_template("query-results.html", q=x[0], o=x[1], a=x[2], useful_results=y)
from googleSearch import googleSearch from time import sleep import cPickle if __name__ == "__main__": term_equal = ("food", "provisions", "nutrition", "nourishment","something+to+eat", "eat", "provisions", "viands", "pabulum", "vivers") term_condition = ("price", "availability", "condition", "emergency", "shortage", "waste", "supply", "demand", "quality", "crisis", "riots", "aid") for equal in term_equal: for condition in term_condition: # print "%s+%s" %(equal, condition) query = "%s+%s" %(equal, condition) #print query results = googleSearch(query) cPickle.dump(results,open(query+'.p','wb')) sleep(1)