Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import wikipedia
- import speech_recognition as sr
- import datetime
- import time
- import os
- import requests
- import json
- import pyautogui
- import pyttsx3
- import webbrowser
- engine = pyttsx3.init('sapi5')
- voices = engine.getProperty('voices')
- for voice in voices:
- engine.getProperty('voices')
- engine.setProperty('voice', voices[1].id)
- rate = engine.setProperty('rate', 165)
- def speak(audio):
- engine.say(audio)
- engine.runAndWait()
- def greet_1():
- speak('Hello sir! My name is Nebula, How may I assist you?')
- def greeting():
- hour = int(datetime.datetime.now().hour)
- if hour >= 0 and hour<12:
- speak('Good Morning Nick!')
- elif hour>12 and hour<16:
- speak('Good Afternoon Mr. Decker!')
- else:
- speak('Good Evening Sir')
- speak('How may I assist you?')
- def listening():
- # takes microphone input and converts it to text
- r = sr.Recognizer()
- with sr.Microphone() as source:
- print('Speak Now...')
- r.pause_threshold = 1
- audio = r.listen(source)
- try:
- print('Thinking...')
- query = r.recognize_google(audio, language='en-in')
- print('User said:\n')
- print(query)
- except Exception as e:
- print("Sorry I couldnt understand you.")
- return'None'
- return query
- if __name__ == "__main__":
- greeting()
- while True:
- elif 'off' in query:
- os.system('cmd /c "python -m flux_led 192.168.1.104 --off & python -m flux_led 192.168.1.140 --off"')
- elif 'on' in query:
- os.system('cmd /c "python -m flux_led 192.168.1.104 --on & python -m flux_led 192.168.1.140 --on"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement