Advertisement
Guest User

Untitled

a guest
May 6th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1. import subprocess
  2. import wikipedia
  3. import speech_recognition as sr
  4. import datetime
  5. import time
  6. import os
  7. import requests
  8. import json
  9. import pyautogui
  10. import pyttsx3
  11. import webbrowser
  12. engine = pyttsx3.init('sapi5')
  13. voices = engine.getProperty('voices')
  14. for voice in voices:
  15.     engine.getProperty('voices')
  16.     engine.setProperty('voice', voices[1].id)
  17.     rate = engine.setProperty('rate', 165)
  18.  
  19.  
  20. def speak(audio):
  21.     engine.say(audio)
  22.     engine.runAndWait()
  23.  
  24.  
  25. def greet_1():
  26.     speak('Hello sir! My name is Nebula, How may I assist you?')
  27.  
  28.  
  29. def greeting():
  30.     hour = int(datetime.datetime.now().hour)
  31.     if hour >= 0 and hour<12:
  32.         speak('Good Morning Nick!')
  33.     elif hour>12 and hour<16:
  34.         speak('Good Afternoon Mr. Decker!')
  35.     else:
  36.         speak('Good Evening Sir')
  37.     speak('How may I assist you?')
  38.  
  39.  
  40. def listening():
  41.     # takes microphone input and converts it to text
  42.     r = sr.Recognizer()
  43.     with sr.Microphone() as source:
  44.         print('Speak Now...')
  45.         r.pause_threshold = 1
  46.         audio = r.listen(source)
  47.     try:
  48.         print('Thinking...')
  49.         query = r.recognize_google(audio, language='en-in')
  50.         print('User said:\n')
  51.         print(query)
  52.     except Exception as e:
  53.         print("Sorry I couldnt understand you.")
  54.         return'None'
  55.     return query
  56.  
  57.  
  58. if __name__ == "__main__":
  59.     greeting()
  60.     while True:
  61.         elif 'off' in query:
  62.             os.system('cmd /c "python -m flux_led 192.168.1.104 --off & python -m flux_led 192.168.1.140 --off"')
  63.         elif 'on' in query:
  64.             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