-
Notifications
You must be signed in to change notification settings - Fork 4
/
join_google_meet.py
110 lines (90 loc) · 3.93 KB
/
join_google_meet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# import required modules
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException
import time
from record_audio import AudioRecorder
from speech_to_text import SpeechToText
import os
import tempfile
class JoinGoogleMeet:
def __init__(self):
self.mail_address = os.environ.get('email_id')
self.password = os.environ.get('email_password')
# create chrome instance
opt = Options()
opt.add_argument('--disable-blink-features=AutomationControlled')
opt.add_argument('--start-maximized')
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 1,
"profile.default_content_setting_values.media_stream_camera": 1,
"profile.default_content_setting_values.geolocation": 0,
"profile.default_content_setting_values.notifications": 1
})
self.driver = webdriver.Chrome(options=opt)
def Glogin(self):
# Login Page
self.driver.get(
'https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ')
# input Gmail
self.driver.find_element(By.ID, "identifierId").send_keys(self.mail_address)
self.driver.find_element(By.ID, "identifierNext").click()
self.driver.implicitly_wait(10)
# input Password
self.driver.find_element(By.XPATH,
'//*[@id="password"]/div[1]/div/div[1]/input').send_keys(self.password)
self.driver.implicitly_wait(10)
self.driver.find_element(By.ID, "passwordNext").click()
self.driver.implicitly_wait(10)
# go to google home page
self.driver.get('https://google.com/')
self.driver.implicitly_wait(100)
print("Gmail login activity: Done")
def turnOffMicCam(self, meet_link):
# Navigate to Google Meet URL (replace with your meeting URL)
self.driver.get(meet_link)
# turn off Microphone
time.sleep(2)
self.driver.find_element(By.CSS_SELECTOR, 'div[jscontroller="t2mBxb"][data-anchor-id="hw0c9"]').click()
self.driver.implicitly_wait(3000)
print("Turn of mic activity: Done")
# turn off camera
time.sleep(1)
self.driver.find_element(By.CSS_SELECTOR, 'div[jscontroller="bwqwSd"][data-anchor-id="psRWwc"]').click()
self.driver.implicitly_wait(3000)
print("Turn of camera activity: Done")
def checkIfJoined(self):
try:
# Wait for the join button to appear
join_button = WebDriverWait(self.driver, 60).until(
EC.presence_of_element_located((By.CSS_SELECTOR, 'div.uArJ5e.UQuaGc.Y5sE8d.uyXBBb.xKiqt'))
)
print("Meeting has been joined")
except (TimeoutException, NoSuchElementException):
print("Meeting has not been joined")
def AskToJoin(self, audio_path, duration):
# Ask to Join meet
time.sleep(5)
self.driver.implicitly_wait(2000)
self.driver.find_element(By.CSS_SELECTOR, 'button[jsname="Qx7uuf"]').click()
print("Ask to join activity: Done")
# checkIfJoined()
# Ask to join and join now buttons have same xpaths
AudioRecorder().get_audio(audio_path, duration)
def main():
temp_dir = tempfile.mkdtemp()
audio_path = os.path.join(temp_dir, "output.wav")
# Duration for bot to record audio
meet_link = 'https://meet.google.com/jwc-kwyy-ozq'
duration = 60
obj = JoinGoogleMeet()
obj.Glogin()
obj.turnOffMicCam(meet_link)
obj.AskToJoin(audio_path, duration)
SpeechToText().transcribe(audio_path)
#call the main function
if __name__ == "__main__":
main()