def playmusic():
    SRF.speak("playing music ")
    try:
        os.mkdir("music_folder")
    except FileExistsError:
        pass
    songs = os.listdir("music_folder")

    num = random.randint(0, len(songs))
    os.startfile(os.path.join("music_folder", songs[num - 1]))
def wishme():
    hour = int(datetime.datetime.now().hour)
    if hour >= 0 and hour <= 12:
        SRF.speak("good morning! " + USER)
    elif hour >= 12 and hour < 18:
        SRF.speak("good aftenoon! " + USER)
    else:
        SRF.speak("good evening! " + USER)
def wikipediasearch(query):
    try:
        #SRF.speak("What do you want to search for ?")
        #wikiquery = SRF.takecommand()
        query = query.replace("wikipedia", "")
        query = query.replace("search", "")
        query = query.replace(" on ", "")
        wikiquery = query.replace("for", "")
        SRF.speak('searching wikipedia.....')
        print("this is the wikipedia query :" + wikiquery)
        results = wikipedia.summary(wikiquery, sentences=2)
        time.sleep(2)
        SRF.speak("according to wikipedia")
        print(results)
        SRF.speak(results)
    except:
        SRF.speak("i did not get that !!")
def open_programs_websites(query):
    #chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe %s"
    query = query.replace("open ", "")

    if "youtube" in query:
        SRF.speak("opening youtube")
        #webbrowser.get(chrome_path). open_new_tab("youtube.com")
        webbrowser.open('http://youtube.com', new=2)
        print("opened youtube")

    elif "github" in query:
        SRF.speak("opening github")
        webbrowser.open_new_tab("https://github.com/")

    elif "code" in query:
        SRF.speak("opening visual studio code")
        codepath = "C:\\Users\\Sumesh Pandit\\Desktop\\CPP Code\\main.cpp"
        os.startfile(codepath)
def open_programs_websites(query):
    chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe %s"
    query = query.replace("open ", "")

    if "youtube" in query:
        SRF.speak("opening youtube")
        #webbrowser.get(chrome_path). open_new_tab("youtube.com")
        webbrowser.open('http://youtube.com', new=2)
        print("opened youtube")

    elif "github" in query:
        SRF.speak("opening github")
        webbrowser. open_new_tab("https://github.com/")

    elif "code" in query:
        SRF.speak("opening visual studio code")
        codepath = "C:\\Users\\shikh\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
        os.startfile(codepath)
def googlesearch(query):
    SRF.speak('searching on google.....')
    url = "https://www.google.co.in/search?q=" + (str(query)) + "&oq=" + (
        str(query)
    ) + "&gs_l=serp.12..0i71l8.0.0.0.6391.0.0.0.0.0.0.0.0..0.0....0...1c..64.serp..0.0.0.UiQhpfaBsuU"
    webbrowser.open_new_tab(url)
Beispiel #7
0
import fridayfunctions as FF
from fridayfunctions import playmusic
import speakandrecognizefunctions as SRF
import datetime

WAKE_WORD = "friday"
USER = "******"


def success():
    print("Command executed succesfully :)")


# GREETINGS ON THE START
SRF.speak("Hello !! I am FRIDAY !!")
FF.wishme()
SRF.speak("if u need me to do anything just ask !")

while True:

    # Constantly hearing in the background
    text = SRF.takecommandbackground()

    # Wakes up when it hears the word FRIDAY in the text
    if text.count(WAKE_WORD) > 0:

        SRF.speak("How may i help you ?")
        print("\nListening....")

        # takes the command to do stuff
        text = SRF.takecommand()