예제 #1
0
def engine_speak(text):
    text = str(text)
    engine.say(text)
    engine.runAndWait()
예제 #2
0
def hablar(texto):
    print(texto)
    engine.say(texto)
    engine.runAndWait()
예제 #3
0
            # voices = engine.getProperty('voices')
            # engine.setProperty('voice', voices[1].id)
            # engine.say('Sorry I did not get that')
            # print('Sorry I did not get that')
            # engine.runAndWait()
            pass
        except sr.RequestError:
            # engine.say('my service is down now')
            pass
        return voice_data


while (1):
    voice_data = record_audio()
    if 'exit' in voice_data:
        engine.say('Closing')
        engine.runAndWait()
        break
    respond(voice_data)

# b1=Button(win,text='start',command=record_audio)
# b1.grid(row=5,column=5)

# print('How can I help you')
# voices = engine.getProperty('voices')
# engine.setProperty('voice', voices[1].id)
# engine.say('How can I help you')
# engine.runAndWait()

# win.mainloop()
예제 #4
0
def respond(voice_data):
    try:
        if 'Hey assistant' in voice_data:
            print('listening')

            engine.say('yes tell me')
            engine.runAndWait()
        #     with Microphone() as source1:
        #         r1.adjust_for_ambient_noise(source1,duration=0.2)
        #         audio2=r1.listen(source1,phrase_time_limit=4)
        #         respond(audio2)
        if 'what is your name' in voice_data:

            engine.say('My name is assistant')
            engine.runAndWait()
        if 'search for' in voice_data:
            s_data = voice_data.split('for')
            r_data = s_data[-1]
            engine.runAndWait()
            search = record_audio()
            url = 'https://google.com/search?q= ' + r_data
            webbrowser.get().open(url)
            engine.say("Here is what I found about" + r_data)
            engine.runAndWait()
            try:
                page = wikipedia.summary(r_data, sentences=2)
                engine.say(page)
                engine.runAndWait()
            except:
                print('Nothing to say')
            print("Here is what I found " + search)
        if 'what is the time' in voice_data:
            print(ctime())

            engine.say(ctime())
            engine.runAndWait()
        if 'find location' in voice_data:
            l_data = voice_data.split('location')
            f_data = l_data[-1]
            url = 'https://google.nl/maps/place/' + f_data + '/&'
            webbrowser.get().open(url)
            engine.say('Here is the location ' + f_data)
            engine.runAndWait()
        if 'YouTube' in voice_data:

            engine.say('opening youtube')
            engine.runAndWait()
            print('opening youtube')
            url = 'https://www.youtube.com/'
            webbrowser.get().open(url)
        if 'play' in voice_data:
            p_data = voice_data.split('play')
            pl_data = p_data[-1]
            try:
                pywhatkit.playonyt(pl_data)

                engine.say('playing')
                engine.runAndWait()
                print('playing')
            except:
                print('An error occured')
        if 'app' in voice_data:
            try:
                engine.say('opening whatsapp')
                engine.runAndWait()
                url = ('https://web.whatsapp.com/')
                webbrowser.get().open(url)
            except:
                engine.say('could not open')
                print('could not open')
        if 'Lpu Live' in voice_data:
            engine.say('opening lpulive')
            engine.runAndWait()
            url = 'https://lpulive.lpu.in/lpu-demo1/messages/1408548'
            webbrowser.get().open(url)
        if 'tell me a joke' in voice_data:
            joke1 = pyjokes.get_joke(language='en', category='all')
            print(joke1)

            engine.say(joke1)
            engine.runAndWait()
        if 'translate' in voice_data:
            engine.say('What do you want to translate')
            engine.runAndWait()
            tran = record_audio()
            try:
                p = Translator()
                k = p.translate(tran, dest='hi')
                translated = k.pronunciation
                newVoiceRate = 145
                engine.setProperty('rate', newVoiceRate)
                engine.say(translated)
                engine.runAndWait()
                print(translated)
            except:
                engine.say('Sorry I could not translate')
                engine.runAndWait()
        if 'insta' in voice_data:
            engine.say('opening insta')
            engine.runAndWait()
            url = 'https://www.instagram.com/'
            webbrowser.get().open(url)
        if 'notepad' in voice_data:
            engine.say('What do you want to write')
            engine.runAndWait()
            write_to_file = record_audio()
            file_f = "hello" + '-note.txt'
            with open(file_f, 'w') as myFile:
                myFile.write(write_to_file)
                os.startfile(file_f)
                engine.runAndWait()
        if "today's temperature" in voice_data:
            v_data = voice_data.split(" ")
            vo_data = v_data[-1]
            url = 'https://www.google.com/search?q=%20today%27s%20temperature%20in%20' + vo_data
            webbrowser.get().open(url)
            engine.say(vo_data)
            engine.runAndWait()
        if 'who is' in voice_data:
            try:

                i_data = voice_data.split('who is')
                r_data = i_data[-1]
                res = client.query(r_data)
                engine.say(next(res.results).text)
                engine.runAndWait()
            except:
                pass
        if 'what is the' in voice_data:
            try:
                s_data = voice_data.split('what is the')
                is_data = s_data[-1]
                res = client.query(is_data)
                engine.say(next(res.results).text)
                engine.runAndWait()
            except:
                pass

        if 'calculate' in voice_data:
            try:
                c_data = voice_data.split('calculate')
                cr_data = c_data[-1]
                engine.say(cr_data)
                engine.runAndWait()
            except:
                pass

    except:
        pass
예제 #5
0
def speak(audio):
    engine.say(audio)
    engine.runAndWait()
예제 #6
0
import pyttsx3
from pyttsx3 import engine
engine = pyttsx3.init()
voices = engine.getProperty('voices')
filename = ["RobertFrostRoadNotTaken.txt"]  #Put file name here
b = []
zira = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0"  #Microsoft David
david = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"  #Microsoft Zira
rate = engine.getProperty('rate')
engine.setProperty('rate', rate + -20)  #Change speaking speed
for files in filename:
    f = open(files, 'r')  #Open in read mode
    contents = f.read()
    contents = contents.split('\n')
    b.append(contents[-1])
    f.close()  #Close file
count1 = 0
for element in b:
    count1 = count1 + 1
    if b.count(element) > 1:
        print(element)
        print(filename[count1 - 1])
for voice in voices:
    engine.setProperty('voice', zira)  #Choose voice
    engine.say(contents)
engine.runAndWait()
예제 #7
0
import webbrowser
import os
import smtplib
from pyttsx3 import engine
from email.mime import audio
from pyttsx3.drivers import sapi5
from comtypes.gen import SpeechLib

print("Initializing Jarvis")



engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices',voices[1].id)
engine.say(" Hi Chaitanya")
engine.runAndWait()

def speak(audio):
    engine.say(audio)
    engine.runAndWait()


def wishMe():
    hour = int(datetime.datetime.now().hour)
    if(hour>=0 and hour<12):
        speak("Good Morning!")
    elif hour>=12 and hour<18:
        speak("Good Afternoon!")
    else:
        speak("Good Evening!")
import pyttsx3
from pyttsx3 import engine
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
    engine.setProperty('voice', voice.id)
    engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
예제 #9
0
import pyttsx3
from pyttsx3 import engine

engine = pyttsx3.init()
engine.say("hello world")
import pyttsx3
from pyttsx3 import engine
engine = pyttsx3.init()
ml_voice = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"
fm_voice = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0"
engine.setProperty('voice', fm_voice)
engine.say('Hello, I am Microsoft Zira')
engine.setProperty('voice', ml_voice)
engine.say('Hello I am Microsoft David')
engine.runAndWait()
 def register_data(self):
     if self.var_fname.get() == "" or self.var_email.get(
     ) == "" or self.var_securityQ.get() == "Select":
         messagebox.showerror("Error",
                              "All Fields are Required",
                              parent=self.root)
     elif self.var_pass.get() != self.var_confpass.get():
         messagebox.showerror("Error",
                              "Password and Confrom Password must be same",
                              parent=self.root)
     elif self.var_check.get() == 0:
         messagebox.showerror("Error",
                              "Please agree our Terms and Conditions",
                              parent=self.root)
     elif self.var_lname.get() == "":
         messagebox.showerror("Error",
                              "please enter lastname to proceed",
                              parent=self.root)
     elif self.var_pass.get() == "":
         messagebox.showerror("Error",
                              "please enter password to proceed",
                              parent=self.root)
     elif self.var_confpass.get() == "":
         messagebox.showerror("Error",
                              "please enter confrompass to proceed",
                              parent=self.root)
     elif len(self.var_contact.get()) != 10:
         messagebox.showerror(
             "Error",
             "please enter 10 digit phone number to proceed",
             parent=self.root)
     elif self.var_email.get() == "":
         messagebox.showerror("Error",
                              "please enter email to proceed",
                              parent=self.root)
     else:
         conn = mysql.connector.Connect(host="localhost",
                                        username="******",
                                        password="******",
                                        database="face_recognizer")
         my_cursor = conn.cursor()
         query = ("select * from register where email=%s")
         value = (self.var_email.get(), )
         my_cursor.execute(query, value)
         row = my_cursor.fetchone()
         if row != None:
             messagebox.showerror(
                 "Error",
                 "User already exist,please try another email",
                 parent=self.root)
         else:
             my_cursor.execute(
                 "insert into register values(%s,%s,%s,%s,%s,%s,%s)",
                 (self.var_fname.get(), self.var_lname.get(),
                  self.var_contact.get(), self.var_email.get(),
                  self.var_securityQ.get(), self.var_securityA.get(),
                  self.var_pass.get()))
         conn.commit()
         self.reset_data()
         conn.close()
         messagebox.showinfo("Success",
                             "Register Successfully",
                             parent=self.root)
         engine.say("Your Register has been successfully")
         engine.runAndWait()