AI-NO PICS

Why do I get indent error when running this script [duplicate]

Here is the code
Thanks in advance

import keyboard
from selenium import webdriver
import pyperclip
import openai

def translate_and_input():
    # Get copied text
    text = pyperclip.paste()

    # Open Google Translate website
    driver = webdriver.Chrome()
    driver.get("https://translate.google.com/")

    # Find the text field and paste copied text
    text_field = driver.find_element_by_id("source")
    text_field.send_keys(text)

    # Find the translate button and click it
    translate_button = driver.find_element_by_id("gt-submit")
    translate_button.click()

    # Find the translated text 
    translated_text = driver.find_element_by_id("gt-res-dir-ctr")
    print(translated_text.text)
    pyperclip.copy(translated_text.text)
    print("Translated text copied to clipboard.")

keyboard.add_hotkey('ctrl+alt+t', translate_and_input)

def end_script():
    keyboard.unhook_all()
    exit()

keyboard.add_hotkey('ctrl+alt+e', end_script)

# Wait for the hotkey to be pressed
keyboard.wait()

What Im trying to do is. We have math exercises and Im trying to make a script that automatically translates question from finnish to english then ask for answer in open ai chat bot and then copies that answer to my clipboard

I was trying to run it but it say

IndentationError: unexpected indent

For feedback or comments, reach us on hello@newswire.ae

admin.newswire

admin.newswire

About Author

Leave a comment

Your email address will not be published. Required fields are marked *

You may also like

AI-NO PICS

Looking for best option to export data into achieved then use the data to search for best match based on the certain parameters

We have an old way of storing the archive data in SQL Server and have an algorithm to retrieve the