Last active
September 12, 2023 05:05
-
-
Save KaushikShresth07/26d5dbe37eac5d2190b29c335e5dd24e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import necessary packages | |
| from time import sleep | |
| from selenium import webdriver | |
| from selenium.webdriver.chrome.options import Options | |
| from selenium.webdriver.common.by import By | |
| import warnings | |
| from selenium.webdriver.chrome.service import Service | |
| # Ignore unnecessary warnings | |
| warnings.simplefilter("ignore") | |
| try: | |
| # Define the URL | |
| url = "https://dictation.io/speech" | |
| # Set up Chrome options | |
| chrome_driver_path = 'Brain\\chromedriver.exe' | |
| chrome_options = Options() | |
| chrome_options.headless = False | |
| chrome_options.add_experimental_option('excludeSwitches', ['enable-logging']) | |
| chrome_options.add_argument('--log-level=3') | |
| service = Service(chrome_driver_path) | |
| chrome_options.add_argument("--use-fake-ui-for-media-stream") # Disable UI pop-ups for media access | |
| chrome_options.add_argument("--use-fake-device-for-media-stream") | |
| # Initialize the Chrome driver | |
| driver = webdriver.Chrome(service=service, options=chrome_options) | |
| driver.maximize_window() | |
| driver.get(url) | |
| try: | |
| driver.find_element(by=By.XPATH,value="/html/body/div[1]/div").click() | |
| except: | |
| pass | |
| # Wait for the page to load | |
| sleep(15) | |
| # Execute JavaScript to enable microphone access | |
| driver.execute_script('navigator.mediaDevices.getUserMedia({ audio: true })') | |
| sleep(1) | |
| # Click the "Clear" button to reset | |
| clear_button_xpath = '/html/body/div[3]/section/div/div/div[2]/div/div[3]/div[2]/a[8]' | |
| driver.find_element(by=By.XPATH, value=clear_button_xpath).click() | |
| sleep(1) | |
| # Click the start button | |
| start_button_xpath = "/html/body/div[3]/section/div/div/div[2]/div/div[3]/div[1]/a" | |
| driver.find_element(by=By.XPATH, value=start_button_xpath).click() | |
| print("Microphone is turned on") | |
| except Exception as e: | |
| print("Error: Unable to configure the ChromeDriver properly.") | |
| print("To resolve this error, make sure to set up the ChromeDriver correctly.") | |
| print(e) | |
| # Continuous loop for capturing and writing text | |
| while True: | |
| # Get the text from the dictation interface | |
| text_element_xpath = '/html/body/div[3]/section/div/div/div[2]/div/div[2]' | |
| text = driver.find_element(by=By.XPATH, value=text_element_xpath).text | |
| if len(text) == 0: | |
| pass | |
| else: | |
| # Click the "Clear" button to reset | |
| driver.find_element(by=By.XPATH, value=clear_button_xpath).click() | |
| text = text.strip() | |
| # Write the text to a file | |
| output_file_path = "Body\\SpeechRecognition.txt" | |
| with open(output_file_path, "w") as file_write: | |
| file_write.write(text) | |
driver.execute_script("localStorage.setItem('language','en-in')") # To set lang t0 en-in
driver.execute_script("localStorage.setItem('dictation','< p >< br >< /p >')") # < remove space >
driver.refresh()
driver.execute_script("dictation('clear')") #to clean
this saturday i will upload code to my github you use this if you don't want to wait for 15 second
if kaushik will tell me i will create a website just like this one and you can use it directly offline
no need i have in my jarvis but i am thinking that this help u in youtube
where show them possibilities jarvis
more contact me instagram link
…On Mon, 11 Sept 2023 at 22:55, kbzcraft ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
if kaushik will tell me i will create a website just like this one and you
can use it directly offline
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/KaushikShresth07/26d5dbe37eac5d2190b29c335e5dd24e#gistcomment-4688194>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5DO4Z4NUF356YYFWVEVT4LXZ5CPXBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTENBWGYZTQMZQU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks bro