Beispiel #1
0
    def veto(self, mess, args):
        """Will veto the currently playing track"""
        print mess.getFrom().getStripped().lower()
        registered = usermanager.get_user_real_name(mess.getFrom().getStripped().lower())
        
        if registered:
            vetoed = usermanager.add_veto(mess.getFrom().getStripped().lower())
            if vetoed:
                pytify.playpause()
                speech.say(vetoed)
##            self.broadcast("Veto! %s vetoed: %s by %s" % (mess.getFrom().getStripped().lower(), pytify.getCurrentTrack(), pytify.getCurrentArtist()))
                pytify.next()
                return "Vetoed"
            else:
                return "You already vetoed a song today!"
        else:
            return "You are not authorised to use this system"
			
	def reload(self, mess, args):
		"""Will reload the currently playing track"""
		print mess.getFrom().getStripped().lower()
        pytify.playpause()
        speech.say("Bound to the reload!")
##      self.broadcast("Veto! %s vetoed: %s by %s" % (mess.getFrom().getStripped().lower(), pytify.getCurrentTrack(), pytify.getCurrentArtist()))
        pytify.previous()
        return "Reloaded"
def top_headline():
	news_api = requests.get("https://newsapi.org/v2/top-headlines?country=us&apiKey=")
	news_response = news_api.json()
	top_headline = news_response['articles'][0]['description']
	author = news_response['articles'][0]['author']
	source = news_response['articles'][0]['source']['id']
	speech.say("Your top headline for this morning comes by way of author {}. {}".format(author, top_headline),"en-UK")
Beispiel #3
0
 def tv_progress_did_select(self, tableview, section, row):
     lst = tableview.data_source
     selected_item = lst.items[row]
     lst.selected_row = row
     if lst.action:
         lst.action(lst)
     speech.say(selected_item, 'en-US')
def test_funcs():
    print('Testing basic functions')
    ph = speech.translate('hello world')
    assert ph == ' /HEHLOW WERLD'
    speech.pronounce('PIHTHUN', pitch=32, speed=60, mouth=100, throat=150)
    speech.say('hello')
    speech.sing('YEHSTERDEY5')
Beispiel #5
0
    def playTouch(self):
        '''Items selection and setup'''
        for item in list(self.items):
            '''This remove previous items from the screen'''
            item.remove_from_parent()
            self.items.remove(item)

        for i in range(3):

            a = i + 1
            bnum = len(self.bitlist)
            bit = Bit(parent=self)
            self.items.append(bit)
            bit.position = self.size.x / 4 * a, self.size.y / 2
            bit.size = (200, 200)

            targetBit = self.bitlist[randrange(bnum)]
            bit.name = str(targetBit)
            targetPic = str(targetBit) + '.jpg'
            targetPic = targetPic.lower()
            bit.texture = Texture(targetPic)
            bit.size = (200, 200)
            self.bitlist.remove(targetBit)
            self.showlist.append(targetBit)
            snum = len(self.showlist)

        winbit = self.showlist[randrange(snum)]
        speech.say(winbit)
        self.winTex = str(winbit)
def test_sleep():
    # check that sleep works ok with speech because they both use low-level timers
    # (this is really a test of the audio module)
    print('Testing sleep with speech')
    microbit.sleep(1)
    speech.say('hello world')
    microbit.sleep(1)
Beispiel #7
0
def counter(dursec, durmin, durhour):
    a = dursec
    a += durmin * 60
    a += durhour * 3600
    time.sleep(a)
    speech.say("time up")
    playsound('audios/timup.mp3')
Beispiel #8
0
	def menu_button_selected(self, title):
		if title in ('Continue', 'New Game', 'Play', 'Try Again', 'Launch!'):
			self.dismiss_modal_scene()
			self.menu = None
			self.paused = False
			if title in ('Play', 'Try Again','Launch!'):
				self.new_game()
				speech.say('Attack their ships, ...and try to survive', 'id_ID')
			elif title in ('New Game'):
				self.dismiss_modal_scene()
				self.menu = None
				self.paused = False
				self.show_start_menu()
		elif title in ('Help', 'Instructions'):
			self.dismiss_modal_scene()
			self.menu = None
			self.paused = False
			if title == 'Help':
				self.instruct_menu()
			else:
				self.instruct_menu(bob = 'Launch!')
		elif title in ('Save Score'):
			if self.score > self.highscore:
				with open('SpaceBlaster.highscore', 'w') as f:
					f.write(str(self.score))
					self.highscore = self.score
		else:
			print(title)
Beispiel #9
0
def addalarm(hrs, min, dur, date, mon):
    cur = db.cursor()
    cur.execute(
        "INSERT INTO `alarm`(`hrs`, `min`, `dur`, `date`, `mon`) VALUES (%d,%d,%d,%d,%d)"
        % (hrs, min, dur, date, mon))
    db.close()
    speech.say("Alarm successfully added")
	def login_protocol(self):
		speech.say('Please log into your Jarvis Account to utilize my services', 'en-EN', 0.5)
		self.login_personel = console.login_alert('Please log into your Jarvis Account to utilize services')
		self.login_personel_array = []
		for i in self.login_personel:
			self.login_personel_array.append(i)
		self.name_of_current_subject_array = []
		self.name = self.login_personel_array[0]
		try:
			self.read_from_personal_file = open(self.name.upper(), 'r')
			if self.read_from_personal_file.mode == 'r':
				self.read_from_file = self.read_from_personal_file.read()
				# https://stackoverflow.com/questions/3277503/how-do-i-read-a-file-line-by-line-into-a-list
				self.name_of_current_subject_array.append(self.read_from_file)
				for i in self.name_of_current_subject_array:
					if i.rfind(self.name.upper()):
						speech.say('Welcome back ' + self.name + '!', 'en-EN', 0.5)
						speech.say('How may I be of service?', 'en-EN', 0.5)
						print 'Welcome back ' + self.name + '!'
						print 'How may I be of service?'
						self.idle()
						self.read_from_personal_file.close()
					else:
						speech.say('Pleasure to meet you ' + self.name, 'en-EN', 0.5)
						print 'Pleasure to meet you ' + self.name + '!'
						self.your_own_personal_file_write()
		except:
			speech.say('Pleasure to meet you ' + self.name, 'en-EN', 0.5)
			print 'Pleasure to meet you ' + self.name + '!'
			self.your_own_personal_file_write()
			self.getting_to_know_you()
	def reminders(self):
		self.set_a_reminder = raw_input() 	
		for i in self.set_a_reminder:
			if 'remind' in i:
				reminders.Reminder.title = 'Reminder1'
				speech.say('Okay. I am setting a new reminder for ' + self.reason_for_reminder + ', on ' + self.time_of_reminder, 'en-EN', 0.5)
				print 'Okay. I am setting a new reminder for ' + self.reason_for_reminder + ', on ' + self.time_of_reminder
Beispiel #12
0
def blockListen():
    while True:
        phrase = speech.input()
        speech.say("You said %s" % phrase)
        print "You said " + phrase
        if phrase == "turn off":
            break
Beispiel #13
0
def table_action(sender):
    global lang
    prev_lang = lang
    selected_lang = sender.items[sender.selected_row]
    lang = lang_dict.get(selected_lang, lang)
    if lang not in ('en-US', prev_lang):  # workaround for bug
        speech.say('workaround', lang, speed)
Beispiel #14
0
def say_post():
  name = request.form['name']
  text = request.form['text']
  speech.say(name + " says " + text)
  log_add(name, text)
  templateData = {'name' : name}
  return render_template("piHole_say.html", **templateData)
Beispiel #15
0
def listen(word_sentence,word_sel,rand_sel):
    
    words = []
    flats = []
    rand_sel  = 1

    if (word_sentence == "word"):
        word_file = "c:/Python27/words.txt"
        last_word = "最后一个单词"
    elif (word_sentence == "sentence"):
        word_file = "c:/Python27/sentences.txt"
        last_word = "最后一个句子"
    
    words = open_file(word_file)
    flats = flat_words(words,word_sel)

    if rand_sel == 1:
        random.shuffle(flats)
        
    for i in range(len(flats)):
        word = flats[i]
        print word
        if debug == 0 :
            if i ==(len(flats) - 1):
                speech.say(last_word)
            
            speech.say(word)
            tkMessageBox.showinfo("info",unicode(word,'cp936').encode('utf-8'))
        

    #tkMessageBox.showinfo("info",word)
    return
Beispiel #16
0
def test_funcs():
    print('Testing basic functions')
    ph = speech.translate('hello world')
    assert ph == ' /HEHLOW WERLD'
    speech.pronounce('PIHTHUN', pitch=32, speed=60, mouth=100, throat=150)
    speech.say('hello')
    speech.sing('YEHSTERDEY5')
Beispiel #17
0
def test_sleep():
    # check that sleep works ok with speech because they both use low-level timers
    # (this is really a test of the audio module)
    print('Testing sleep with speech')
    microbit.sleep(1)
    speech.say('hello world')
    microbit.sleep(1)
Beispiel #18
0
def read_weather():
    # Currently, weather will be a dictionary with a comment, temp, and max.
    location = settings.get_preference('location')
    w = get_weather(location)
    say('The weather for %s includes %s' % (location, w['comment']))
    say('It is currently %d. Expect it to get %.2f degrees warmer' %
        (w['temp'], w['max'] - w['temp']))
Beispiel #19
0
def route(destination):
    send_url = 'http://freegeoip.net/json'
    r = requests.get(send_url)
    j = json.loads(r.text)
    lat = j['latitude']
    lon = j['longitude']
    city = j['city']
    print("You are at " + str(city))
    speech.say("You are at " + str(city))
    bingMapsKey = "Ah1ha8z7d6jaHFMiWaokDWkH_x1Uk733r1PrUFD5rEsbIJlAxXCkSeCkW7DVDh80"
    longitude = lon
    latitude = lat
    encodedDest = urllib.parse.quote(destination, safe='')
    routeUrl = "http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0=" + str(
        latitude) + "," + str(
            longitude) + "&wp.1=" + encodedDest + "&key=" + bingMapsKey
    request = urllib.request.Request(routeUrl)
    response = urllib.request.urlopen(request)

    r = response.read().decode(encoding="utf-8")
    result = json.loads(r)

    itineraryItems = result["resourceSets"][0]["resources"][0]["routeLegs"][0][
        "itineraryItems"]
    for item in itineraryItems:
        print(item["instruction"]["text"])
        speech.say(item["instruction"]["text"])
Beispiel #20
0
def read_weather():
    # Currently, weather will be a dictionary with a comment, temp, and max.
    location = settings.get_preference('location')
    w = get_weather(location)
    say('The weather for %s includes %s' %(location, w['comment']))
    say('It is currently %d. Expect it to get %.2f degrees warmer'
        %(w['temp'], w['max'] - w['temp']))
Beispiel #21
0
def doHealthSignIn():
    clipboard = paste()
    copySelected()
    sleep(0.01)
    keybd_event(46, 0, 0, 0)
    keybd_event(46, 0, KEYEVENTF_KEYUP, 0)
    receiver = '测控一班666'
    msg = paste()
    copy(clipboard)
    time = datetime.now()
    lines = len([each for each in msg.split('\n') if each])
    myMsg = '\n{}.本人廖辰玮,目前在江西省高安市,今日本人和家人体温正常,我承诺本人身体健康情况和行程信息准确上报,服从学校疫情防控要求。'
    if msg.find('今日本人和家人体温正常') != -1 and msg.find('廖辰玮') != -1:
        say('您今日已完成签到')
    elif msg.find('今日本人和家人体温正常') != -1:
        msg = msg + myMsg.format(lines)
        code = QQSend(receiver, msg.replace('\n\n', '\n'))
        if code == -1:
            say('签到失败,请斋主打开群聊界面')
        else:
            say('签到成功')
    else:
        msg = '{}.{}'.format(time.month, time.day) + myMsg.format(1)
        code = QQSend(receiver, msg, False)
        if code == -1:
            say('签到失败,请斋主打开群聊界面')
        else:
            say('未找到别人的签到信息,请斋主手动发送第一条')
Beispiel #22
0
 async def speak(self, instance, value):
     if isinstance(value, (list, tuple)):
         value, = value
     language = self.language.value[0]
     rate = self.rate.value[0]
     print(f'Saying {value!r} in language {language} at rate {rate}')
     speech.say(value, language, rate)
 def speakScrambledWord(self):
     s = str(self.scrambledLabel.text())
     speech.say("Unscramble : ")
     for char in s:
         speech.say(char + '...')
         # speech.say(phrase)
     self.lineEdit.setFocus()
Beispiel #24
0
def checkTime():
    while True:
        csvFileName = "G:\\Python27\\Gofer_voice\\remainders\\remainders.csv"
        df = pd.read_csv(csvFileName)
        remainder_time = df.time  #you can also use df['column_name']
        gdate = time.strftime("%d/%m/%Y")
        gtime = time.strftime("%I:%M")
        print gdate + ',' + gtime
        print remainder_time
        print len(remainder_time)
        if gtime in remainder_time:
            print remainder_time.index(gtime)
            print 'yes'
        #print df.activity[3]
        i = 0
        for rem in remainder_time:
            i = i + 1
            if rem == gtime:
                print 'you got a remainder'
                print df.activity[i - 1]
                speech.say('you got a remainder')
                speech.say(df.activity[i - 1])
                removeActivity(i - 1)
        print 'sleeping'
        time.sleep(30)
Beispiel #25
0
def button_next_tapped(sender):
    global g_current_db_index
    global G_DB_ROW_LENGTH
    global g_db_id
    global g_db_element
    global g_db_chapter
    global g_db_section

    try:
        conn = sqlite3.connect("wanglu_linguistic_material.db")
        cursor = conn.cursor()
        if g_current_db_index == G_DB_ROW_LENGTH:
            g_current_db_index = 1
        cursor.execute(
            """SELECT * FROM wanglu_linguistic_material WHERE chapter=? AND section=? AND number=?""",
            (
                g_db_chapter,
                g_db_section,
                g_current_db_index,
            ))
        row = cursor.fetchone()
        g_current_db_index = g_current_db_index + 1
        g_db_id = row[1]
        g_db_element = row[4]
        speech.say(g_db_element, 'en-UK', 0.5)
        conn.close

    except Error:
        print(Error)
Beispiel #26
0
def blockListen():
    while True:
        phrase = speech.input()
        speech.say("You said %s" % phrase)
        print "You said " + phrase
        if phrase == "turn off":
            break
 def run(self):
     say('How can I help you?')
     while 1:
         self.label.show_listening()
         voice_data = listen(self.label.show_processing)
         self.execute(voice_data, self.root)
         time.sleep(5)
Beispiel #28
0
def execute(cmd):
    cmd,params = [c.strip() for c in cmd.split(':')]
    if cmd == 'say':
        speech.say(params)
    if cmd == 'pwr' and params == 'off':
        import win32api
        win32api.ExitWindowsEx(24,0)
Beispiel #29
0
def addActivity(result):

    for t in to:
        if t in result:
            tpos = result.find(t)
            factivity = result[tpos + len(t):]
            print factivity
            r_time = get_time(result)
            while r_time == -1:
                speech.say('set the time of the remainder')
                r_time = hear.hear()
                r_time = get_time(r_time)
                if r_time == -1:
                    speech.say('that is an invalid time format')
            break

    else:
        speech.say('ya sure, what sbould i remind you of')
        factivity = hear.hear()
        print factivity
        r_time = get_time(factivity)
        if r_time == -1:
            speech.say('set the time of the remainder')
            r_time = hear()
            r_time = get_time(r_time)

    rem_list = os.listdir("remainders")
    #count = len(rem_list) + 1
    remainderFile = "remainders\\remainders.csv"
    factivity = str(r_time) + ',' + str(factivity)
    print 'saving remainder'
    file_remainder = open(remainderFile, "a")
    file_remainder.write('\n' + factivity)
    file_remainder.close()
    speech.say(factivity + ' is saved')
Beispiel #30
0
def detectedCallback():

    arduino.write('1'.encode())

    try:
        play_audio_file(select(config.get('wav', 'listening')))

        reqText = speech.recognize()
        if (reqText):
            # submit request
            logger.info('Request: {0}'.format(reqText))
            response = requests.post(config.get('core_service', 'url'),
                                     json={'text': reqText})

            data = response.json()
            logger.info('Response: {0}'.format(data))
            speech.say(data.get('say'), local_tts)

            media = data.get('play')
            if (media):
                process = play_audio_file_async(media, 0.05)
                logger.debug('Playing media file: {0}'.format(media))
                logger.debug('pid={0}'.format(str(process.pid)))
    except Exception as e:
        logger.exception("message")

    arduino.write('0'.encode())
Beispiel #31
0
def speak_the_time():
    h = hours
    am_pm = am
    if h >= 12:
        am_pm = pm
    if h > 12:
        h = h - 12
    if minutes == 0:
        # The time is twelve pm exactly
        speech.say(preamble + digits[h] + " " + am_pm + " exactly")
    else:
        if minutes < 10:
            # The time is twelve o four pm
            speech.say(preamble + digits[h] + " o " + digits[minutes] + " " +
                       am_pm)
        elif minutes < 20:
            # The time is twelve eighteen pm
            speech.say(preamble + digits[h] + " " + digits[minutes] + " " +
                       am_pm)
        else:
            mins_tens = int(minutes / 10)
            mins_units = minutes % 10
            if mins_units == 0:
                # The time is twelve twenty pm
                speech.say(preamble + digits[h] + " " + tens[mins_tens] + " " +
                           am_pm)
            else:
                # The time is twelve twenty four pm
                speech.say(preamble + digits[h] + " " + tens[mins_tens] + " " +
                           digits[mins_units] + " " + am_pm)
Beispiel #32
0
 def take_a_selfie(self, filename='.temp.jpg'):
     self.name = raw_input()
     self.selfie = raw_input()
     if 'selfie' in self.selfie:
         img = photos.capture_image()
         if img:
             img.save(filename)
             console.show_image(filename)
             speech.say(self.name + ', you look stunning!')
             print self.name + ', you look stunning!'
             speech.say(
                 'Would you like to save your master piece in a custom album?'
             )
             print 'Would you like to save your master piece in a custom album?'
             self.to_save_or_not_to_save = raw_input()
             if 'ye' in self.to_save_or_not_to_save:
                 photos.create_album(self.name + 's Album')
                 speech.say(
                     'Okay. I have created your own custom album to save your legendary pic.'
                 )
                 print 'Okay. I have created your own custom album to save your legendary pic.'
                 speech.say(
                     'Hold the image to save your elegant pic in your custom album'
                 )
                 print 'Hold the image to save your elegant pic in your custom album'
                 self.idle()
             else:
                 speech.say(
                     'Affirmative... Your photo will be deleted after this session.'
                 )
                 print 'Affirmative... Your photo will be deleted after this session.'
                 self.idle()
     console.clear()
Beispiel #33
0
 def speakScrambledWord(self):
     s = str(self.scrambledLabel.text())
     speech.say("Unscramble : ")
     for char in s:
         speech.say(char + '...')
         # speech.say(phrase)
     self.lineEdit.setFocus()
Beispiel #34
0
    def do_aom(phrase,listener):
        if phrase == 'green':
            aom = 'GreenAOM'
        elif phrase == 'red':
            aom = 'MatisseAOM'
        elif phrase == 'pulse':
            aom = 'PulseAOM'
        elif phrase == 'yellow':
            aom = 'YellowAOM'
        elif phrase == 'stop':
            print 'stop listening'
            listener.stoplistening()
            return
        elif phrase == 'servo':
            print 'PMservo flip'
            ins = qt.instruments['PMServo']
            if ins.get_position() == ins.get_in_position():
                ins.move_out()
            else:
                ins.move_in()
            return
        elif phrase=='power':
            power = '{:.0f} nano waat'.format(qt.instruments['powermeter'].get_power()*1e9)
            print 'power: ', power
            speech.say(power)
            return
        else:
            print 'Not understood'

        if qt.instruments[aom].get_power() == 0.:
            print 'Turning on', aom
            qt.instruments[aom].turn_on()
        else:
            print 'Turning off', aom
            qt.instruments[aom].turn_off()
Beispiel #35
0
 def initialization(self):
     speech.say('Initializing')
     print 'Initializing...'
     cwd = os.getcwd()
     print cwd + '\n\n'
     time.sleep(3)
     speech.say('Configuring Settings')
     print 'Configuring Settings...'
     cpr = sys.copyright
     print cpr + '\n\n'
     time.sleep(3)
     speech.say('Re-configuring Localized Settings...')
     print 'Re-configuring Localized Settings...\n\n'
     time.sleep(3)
     speech.say(
         'Welcome to the Beta Version of Jarvis. Your personal assistant...'
     )
     print 'Welcome to the Beta Version of Jarvis. Your personal assistant...'
     time.sleep(3)
     self.current_date_eastern_time_zone()
     self.current_eastern_standard_time()
     time.sleep(10)
     speech.say('Lets get acquainted with each other. What is your name?')
     print 'Lets get acquainted with each other. What is your name?'
     time.sleep(3)
     self.get_person_at_hand()
     #self.your_own_personal_file_write()
     self.your_own_personal_file_read()
Beispiel #36
0
    def draw(self):
        global start_t
        global tlist, ptr, plist
        global flist
        global doblock
        global lan1
        global wait
        if speech.is_speaking():
            self.lastt = time.time()
        else:
            if doblock:
                if len(self.children) < 2:

                    k = 1
                    j = 1
                    for t in first:
                        #    					print("t=",t,self.size)
                        self.s2 = SpriteNode(t)
                        rat = self.size.y / self.s2.size.y
                        rat = rat * 0.1
                        self.s2.size = self.s2.size * rat
                        self.s2.position = [
                            self.size.x * k / 9, self.size.y * j / 5
                        ]
                        self.s2.position = [
                            self.size.x * (k / 9.),
                            self.size.y * (1.1 - j / 5.)
                        ]
                        # self.s2.position[0]=200
                        # self.s2.position.y=self.size.y*random.random()
                        #    					print(self.s2.position)
                        k = k + 1
                        if (k == 8):
                            k = 1
                            j = j + .75
                        self.add_child(self.s2)
                return

            if ptr >= len(plist) and not (
                    speech.is_speaking()) and time.time() > self.lastt + 5.0:
                startit()
            if ptr < len(plist) and time.time() > self.lastt + 1.5:
                self.s2 = None
                p = os.getcwd() + "/" + plist[ptr].strip() + ".png"
                #    			print(p)
                self.s2 = SpriteNode(p)
                self.s2.position = self.size / 2
                rat = self.size.y / self.s2.size.y
                self.s2.size = self.s2.size * rat
                self.add_child(self.s2)
                if ptr == 0:
                    sleep(wait)
                if (len(self.children) > 1):
                    self.children[0].remove_from_parent()


#    			print(p,tlist[ptr])
                speech.say(tlist[ptr], lan1)
                # self.touch_began(xy)
                ptr = ptr + 1
Beispiel #37
0
def getpnr():
    with urllib.request.urlopen(
            "https://api.railwayapi.com/v2/pnr-status/pnr/4244155114/apikey/4khkpfnhvz/"
    ) as url:
        data = json.loads(url.read().decode())
        cs = data['passengers'][0]
        speech.say(str(cs['current_status']).replace('/', ' '))
def say(sentence):    
    open_eyes()
    if use_voice:
        speech.say(sentence, speed=120, pitch=100, throat=190, mouth=190)
    else:
        display.scroll(sentence, delay=75)
    close_eyes()
Beispiel #39
0
def initializeUserData():
    '''
    Should only be used in tests.
    Collects user data every time program starts.
    In official version this should store data permanently,
    not to memory.
    '''

    wantedName=False #boolean variable which states that the user is OK with his/her name or not
    while not wantedName:
        speech.say('what is your name?')
        name=speech.input() #stores user input to name variable
        speech.say('your name is ' + name)
        speech.say('is this o k with you')
        response=speech.input() #stores user response to previous question to variable
        if response=='Yes':
            wantedName=True #user is OK with name
    gender=None #creates gender variable. we dont know users gender yet (hence the None)
    doneGender=False
    while not doneGender: #same thing  as before
        speech.say(name + ', What is your sex, male or female?')
        gender=speech.input() #user's response
        if gender=='Male' or gender=='Mail': #pyspeech misinterprets 'male' for 'mail' sometimes
            pronoun='sir' #this is what CHRIS will use to refer to the user
            doneGender=True
        if gender=='Female':
            pronoun='mam'
            doneGender=True
    speech.say('O K , we\'re done')
    ret_info=[name, gender, pronoun] #returns the name, gender, and pronoun of the user in form of list
    return ret_info
	def callback(self, phrase, listener):
		if ((phrase == "Stop") or (phrase == "STOP") or (phrase == "stop")):
			listener.stoplistening()
			
		if ((phrase == "Next") or (phrase == "NEXT") or (phrase == "next")):
			listener.stoplistening()
			
		speech.say(phrase)
Beispiel #41
0
 def rate_adjusted_cb(self, get):
     speech.rate = int(get.get_value())
     speech.say(_("rate adjusted"))
     f = open(os.path.join(self.activity.get_activity_root(), 'instance',  'rate.txt'),  'w')
     try:
         f.write(str(speech.rate))
     finally:
         f.close()
Beispiel #42
0
 def pitch_adjusted_cb(self, get):
     speech.pitch = int(get.get_value())
     speech.say(_("pitch adjusted"))
     f = open(os.path.join(self.activity.get_activity_root(), 'instance',  'pitch.txt'),  'w')
     try:
         f.write(str(speech.pitch))
     finally:
         f.close()
Beispiel #43
0
def button_action(sender):
    global lang
    v['switch1'].action = brit_switch_action
    text = textview.text
    if text == '':
        speech.say('Please tell me something to say.', lang, 0.1) 
    else:
        speech.say(text, lang, 0.1) 
Beispiel #44
0
 def computer(self, mess, args):
     if 'i order you to say' in args.lower():
         pytify.playpause()
         new_string = args.lower().replace("i order you to say", '')
         speech.say(new_string)
         pytify.playpause()
     else:
         return "I didn't understand that command"
  def handle_button_action(self, name, sender):
    BUTTON_PREFIX = 'button_'
    INFO_PREFIX = 'info_'
    
    if name == 'button_start_speech':
      speech.say(sample_text.get_sample_text(), 'de', 1.0 * self.conf.rechtschreibung.speech_speed / 100.0)
      
    elif name == 'button_stop_speech':
      speech.stop()
    
    elif name == 'button_load_mode':
      self.load_mode_start(LOAD_MODE_RULESET)
    
    elif name == 'button_load_reference_mode':
      self.load_mode_start(LOAD_MODE_REFERENCE)
    
    elif name == 'button_save_mode':
      self.save_mode_start()
    
    elif name == 'button_open_app_control_view':
      self.open_app_control_view()

    elif name == 'button_open_top_navigation_view':
      self.open_top_navigation_view()

    elif name == 'button_open_statistics_view':
      self.open_statistics_view()

    elif name == 'button_close_top_navigation_view':
      self.close_top_navigation_view()

    elif name == 'button_icon_rechtschreibung':
      self.button_icon_rechtschreibung()

    elif name.startswith(BUTTON_PREFIX):
      view_name = name[len(BUTTON_PREFIX):]
      child_view = self.find_subview_by_name(view_name)
      if child_view != None:
        view = self.find_subview_by_name(NAME_NAVIGATION_VIEW)
        view.push_view(child_view)
        return 1
        
      else:
        logger.warning("cannot find subview '%s" % view_name)
      
    elif name.startswith(INFO_PREFIX):
      info_name = name[len(INFO_PREFIX):]
      rule_info = self.rule_doc_manager.get_rule_info_by_attr_name(info_name)
      
      if rule_info:
        self.info_popup.present(rule_info, close_label=words.schlieszen(c=rulesets.C_BOS))
        
      else:
        logger.error("cannot find info text for %s" % info_name)
        
    else:  
      super(MainViewController, self).handle_button_action(name, sender)
Beispiel #46
0
	def before_present(self):
		word = self.recite.pickone()
		if word is None:
			self.close()
		else:
			self[LABEL_WORD_NAME].text = word.word
			self[LABEL_TOTAL_NUM_NAME].text = str(self.recite.reciting_length())
			if self.auto_speech:
				speech.say(word.word, 'en-US')
Beispiel #47
0
def test_timing():
    # test that speech takes the correct amount of time over many runs
    print('Testing timing of say function')
    for i in range(5):
        start = microbit.running_time()
        speech.say('hello world')
        microbit.sleep(1)
        stop = microbit.running_time()
        assert 800 < stop - start < 815
	def speaknowButtonTapped(self, sender):
		assert sender.name == 'speakTimeButton', 'Invalid button name: ' + sender.name
		# Get the say seconds preference
		isSaySeconds = sender.superview['speakSecondsSwitch'].value
		if traceFlag: print 'isSaySeconds current value now->>' + str(isSaySeconds)
			
		timeMessage = self.getCurrentLocalTimeAnnouncement(isSaySeconds)
		if traceFlag: print 'Time message to announce ->>' + timeMessage
		speech.say(timeMessage,locale, speechDelay)
Beispiel #49
0
def readFeeds():
    url = "http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss"
    rootfeed = feedparser.parse(url)
    speech.say("Today's top headlines")
    
    titles = []
    for entry in rootfeed["entries"]:
        titles.append(entry.title)
        print (entry.title)
    return titles
    #speech.say("That's all of today's top headlines")
 def __init__(self, parent=None):
     super(HighscoresDialog, self).__init__(parent)
     self.setupUi(self)
     self.readScores()
     i = 1
     for item in self.scores:
         self.listWidget.addItem(QString('%i. %s. Score : %i' % (i, item, self.scores[item][1])))
         i += 1
     self.listWidget.setCurrentItem(self.listWidget.item(0))
     speech.say(str(self.listWidget.currentItem().text()) + '.')
     self.listWidget.currentRowChanged.connect(self.speakItem)
Beispiel #51
0
    def speak_task(self, task):
        """Recite the provided task"""

        if not task:
            return
        if task.tags:
            fmt = "Task number {}, priority: {}, {}, This task has the following tags: {}"
            msg = fmt.format(task.id, task.priority, task.note, " and ".join(task.tags.split()))
        else:
            fmt = "Task number {}, priority: {}, {}, This task does not have any tags."
            msg = fmt.format(task.id, task.priority, task.note)
        speech.say(msg, self.language, self.speech_rate)
Beispiel #52
0
 def button_pressed(self, sender):
     user_text = self['user text'].text
     assert user_text  # buttons will not be enabled if there is no text
     # method 4: using sender.name to decide how to respond
     if   sender.name == 'alert':     self.console_alert(user_text)
     elif sender.name == 'hud_alert': self.console_hud_alert(user_text)
     elif sender.name == 'popover':   self.popover(user_text)
     elif sender.name == 'print':     print(user_text)
     elif sender.name == 'say':       speech.say(user_text)
     else:  # this should never happen!
         print('button_pressed({})'.format(sender.name))
         assert False  # panic
Beispiel #53
0
def shuffle():
    global music
    x = getRandomFile(path + '/music')
    tasks = getoutput('ps -A')
    if 'omxplayer.bin' in tasks:
        # kill omxplayer
        os.killpg(music.pid, SIGTERM)
    # start any music file
    say(x[: - 4])
    music = subprocess.Popen(["omxplayer", "-o", "local", path + '/music/' + x],
                             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                             preexec_fn=os.setsid)
Beispiel #54
0
def callback(phrase, listener):
    print ": %s" % phrase
    if phrase == "turn off":
        speech.say("Goodbye.")
        listener.stoplistening()
        sys.exit()
    else:
       # print(phrase.split())
        spoken_input = phrase.split()
       # print(spoken_input)
        spoken_command = spoken_input[len(spoken_input) - 1]
       # print(spoken_command)
        activate_home(spoken_command)
 def live_recognize(self):
     data = self.record()
     if(data == False):
         return ""
     else:
         is_broken_connection = True
         while is_broken_connection: 
             try:
                 recognized_audio = self.recognize(data)
                 is_broken_connection = False
             except Exception:
                 speech.say("Connection error.")
                 is_broken_connection = True 
         return recognized_audio
	def inputSpeech(self):
		print "Hello"
		file = open("Bill.txt","w");
		response = "NO"
		response1 = "Google"
		speech.say("Hello!!! Welcome to speech recognition for the visually impaired")

		#while((response != "YES") or (response != "Yes") or (response != "yes")):
		while((response == "NO") or (response == "No") or (response == "no")):
			speech.say("Please enter your search query")
			response1 = speech.input("Say something, please.")
			speech.say("You said " + response1)
			print response1
			speech.say("Is this what you said?")
			
			response = speech.input("Is it ok?")
			response=str(response)
			
			
				
			print response
			#while((response != "No") or (response != "NO") or (response != "no") or (response != "YES") or (response != "Yes") or (response != "yes")):
				#print "Please say yes or no"
				#speech.say("Please say   yes    or   no   ")
				#response= speech.input("Please say yes or no")
				#print response
				
		return response1
Beispiel #57
0
    def _joystick(self):

        while True:
            if self.flag == True:
                self.flag = False
                print "self.num=",self.num
                if self.num == 1:
                    self.client.send('set_goal %f %f %f'%(34.373,26.394,0.010))#wp1
                    print "set"
                    self.client.recv()
                elif self.num == 2:
                    #self.num+=1
                    if self.pass_flag == False:
                        self.client.send('set_goal %f %f %f'%(30.030,30.311,3.115))#wp2
                        self.client.recv()
                        self.num = 7
                    else:
                        self.client.send('set_goal %f %f %f'%(30.030,30.311,3.115))#wp2
                        self.client.recv()
                        self.num = 7
                elif self.num == 4:
                    self.client.send('set_goal %f %f %f'%(38.641,27.841,-0.405))#3
                    self.client.recv()
                elif self.num == 5:
                    self.client.send('set_goal %f %f %f'%(37.690,25.940,0.003))#
                    self.client.recv()
                elif self.num == 6:
                    print "555555555555"
                    self.client.send('set_goal %f %f %f'%(18.743,34.158081,-1.222))#18.743,34.158081,-1.222
                    self.client.recv()
                elif self.num == 7:
                    self.client.send('set_goal %f %f %f'%(19.643,30.088081,-2.628))#6
                    self.client.recv()
                elif self.num == 8:
                    self.client.send('set_goal %f %f %f'%(34.586,29.345,0.072))#wp311
                    self.client.recv()
                elif self.num == 9:
                    self.client.send('set_goal %f %f %f'%(34.586,29.345,0.072))#wp3
                    self.client.recv()
                elif self.num == 11 and self.follow_flag == False:
                    speech.say("Bye Bye, I will go back to the last location.")
                    self.client.send('set_goal %f %f %f'%(34.586,29.345,0.072))#wp3
                    self.client.recv()
                    self.follow_flag_1 = False
                    self.num+=1
                elif self.num == 13:
                    self.client.send('set_goal %f %f %f'%(36.850,32.630,1.554))#wp4
                    self.client.recv()
Beispiel #58
0
def connectToWiimote():
    global mac, wm, disFlag, batteryCheck
    while (mac == None):
        connAttempt()
    if mac in subprocess.check_output(["hcitool", "con"]):
        wmInfo = str(wm.state)
        batteryLife = int(wmInfo[wmInfo.index('\'battery\': ') + 11:wmInfo.index('}')])
        if batteryLife <= 15 and batteryCheck == False:
            say('Batteries are low')
            batteryCheck = True
    elif disFlag == False:
        say('Wiimote disconnected.')
        disFlag == True
        connAttempt()
    elif disFlag == True:
        connAttempt()
Beispiel #59
0
def button_tapped(sender):
	button_name = sender.name
	label_word = sender.superview[LABEL_WORD_NAME]
	textview_meaning = sender.superview[TEXTVIEW_MEANING_NAME]
	if button_name == BUTTON_ERROR_NAME:
		sender.superview.recite.record_error()
	elif button_name == BUTTON_SHOW_NAME:
		sender.superview[BUTTON_RIGHT_NAME].enabled = True
		sender.superview[BUTTON_ERROR_NAME].enabled = True
		textview_meaning.text = sender.superview.recite.current_word().meaning
		return
	elif button_name == BUTTON_EXIT_NAME:
		sender.superview.close()
		return
	elif button_name == BUTTON_MENU_START_NAME:
		sender.superview.start2recite	= True
		sender.superview.close()
		return
	elif button_name == BUTTON_MENU_EXIT_NAME:
		sender.superview.start2recite = False
		sender.superview.close()
		return
	elif button_name == BUTTON_SPEAK_NANE:
		speech.say(label_word.text, 'en-US')
		return
	elif button_name == BUTTON_ERROR_NUM_NAME:
		error_view = ui.load_view('ErrorList')
		textview_error_list = error_view[TEXTVIEW_ERROR_LIST_NAME]
		textview_error_list.text = '\n'.join([str(x) for x in sender.superview.recite.err_words])
		textview_error_list.editable = False
		error_view.present(orientations=['portrait'], hide_title_bar=True)
		error_view.wait_modal()
		return
	elif button_name == BUTTON_REMOVE_NAME:
		sender.superview.recite.remove_familiar()
	sender.superview[BUTTON_RIGHT_NAME].enabled = False
	sender.superview[BUTTON_ERROR_NAME].enabled = False
	word = sender.superview.recite.pickone()
	if word is None:
		sender.superview.close()
	else:
		label_word.text = word.word
		textview_meaning.text = ''
		sender.superview[LABEL_RECITED_CNT_NAME].text = str(sender.superview.recite.current_index+1)
		sender.superview[LABEL_ERR_CNT_NAME].text = str(sender.superview.recite.error_cnt())
		if sender.superview.auto_speech:
			speech.say(word.word, 'en-US')
Beispiel #60
0
def initialize_home():
    global user_id
    user_id = pyfaces.recognize_face()
    print(user_id)
    #user_id = 'xyzxxxx'
    global Mode
    global done
    global turn_off
    TrainingDictionary = load_training_data()
    print(TrainingDictionary)
    if (user_id in TrainingDictionary):
        print("You have already visited i-home. The home is trained by your habit. Do you like the home to run in your personalized mode. say YES or NO")
        speech.say("You have already visited i-home. The home is trained by your habit. Do you like the home to run in your personalized mode. say YES or NO")
        listener = speech.listenforanything(callback)
        done=0
        while done!=1:
                continue            
        
        # it will go in while loop only when default mode is selected
        if Mode=='default':
            print 'in default mode'
            while listener.islistening():
                text = raw_input("> ")
                #text = 'asd'
                if turn_off==1:
                    sys.exit()
                elif text == "turn off":
                    listener.stoplistening()
                    sys.exit()
                else:
                    speech.say(text)
            #print(" I am outside the callback")
        #print(Mode)
        elif Mode=='personal':
            print 'in personal mode'
            spoken_command1 = TrainingDictionary[user_id][0]
            spoken_command2 = TrainingDictionary[user_id][1]
            #print(spoken_command1)
            #print(spoken_command2)
            activate_home(spoken_command1, spoken_command2)
    else:
        print 'New user found, set to defualt spoken mode'
        speech.say('New user found, set to defualt spoken mode')
        #for new user
        listener = speech.listenforanything(callback)
        # it will go in while loop only when default mode is selected
        while listener.islistening():
            text = raw_input("> ")
            if turn_off==1:
                    sys.exit()
              
            elif text == "turn off":
                listener.stoplistening()
                sys.exit()
            else:
                speech.say(text)