online class automation (google meet)

 import pyttsx3

from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
import pyautogui
from playsound import playsound
import time
import speech_recognition as sr
import pyaudio
ghs = 1
r = sr.Recognizer()

askformeet = "what is your online class link\n"
classurl = input(askformeet)
browser = webdriver.Chrome('D:\\chromedriver.exe')

browser.get('https://accounts.google.com/b/0/AddMailService')
time.sleep(1)
login = browser.find_element_by_xpath('//*[@id="identifierId"]')
login.send_keys('yourgmailid@gmail.com')
login.send_keys(Keys.ENTER)
time.sleep(1)
loginpwd = browser.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input')
loginpwd.send_keys('your password')
loginpwd.send_keys(Keys.ENTER)
time.sleep(3)
browser.get(classurl)
time.sleep(2)
pyautogui.press('TAB')
pyautogui.press('TAB')
pyautogui.press('enter')
time.sleep(7)
join = browser.find_element_by_xpath('//*[@id="yDmH0d"]/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span/span')
join.click()
while ghs == 1:


 print('while loop started')









 import pyaudio
 import wave

 # the file name output you want to record into
 filename = "na.wav"
 #  set the chunk size of 1024 samples
 chunk = 1024
 # sample format
 FORMAT = pyaudio.paInt16
 # mono, change to 2 if you want stereo
 channels = 1
 # 44100 samples per second
 sample_rate = 44100
 record_seconds = 5
 # initialize PyAudio object
 p = pyaudio.PyAudio()
 # open stream object as input & output
 stream = p.open(format=FORMAT,
                channels=channels,
                rate=sample_rate,
                input=True,
                output=True,
                frames_per_buffer=chunk)
 frames = []
 print("Recording...")
 for i in range(int(44100 / chunk * record_seconds)):
    data = stream.read(chunk)
    # if you want to hear your voice while recording
    # stream.write(data)
    frames.append(data)
 print("Finished recording.")
 # stop and close stream
 stream.stop_stream()
 stream.close()
 # terminate pyaudio object
 p.terminate()
 # save audio file
 # open the file in 'write bytes' mode
 wf = wave.open(filename, "wb")
 # set the channels
 wf.setnchannels(channels)
 # set the sample format
 wf.setsampwidth(p.get_sample_size(FORMAT))
 # set the sample rate
 wf.setframerate(sample_rate)
  # write the frames as bytes
 wf.writeframes(b"".join(frames))
 # close the file
 wf.close()
 

 r = sr.Recognizer()





 with sr.AudioFile(filename) as source:
     audio = r.listen(source)
     try:
        text = r.recognize_google(audio)
        print('working on it.....')
        print(text)
        mamsaid = text.lower()
        if 'aditya' in mamsaid:
          print('mam took your name')
          playsound("newringtone2020hindi.mp3")
        if 'bye' in mamsaid:
            pyautogui.click(797,762)
            time.sleep(1)
            pyautogui.click(797,762)
            ghs = ghs + 4
        if 'bye' in mamsaid:
         pyautogui.click(798,816)
         time.sleep(1)
         pyautogui.click(798,816)
         ghs = ghs + 4
     # recognize (convert from speech to text)
     except:
        print('nothing fancy goning on')

Comments