r.listen来源需要永恒记录

问题描述

''' 从硒导入webdriver 导入时间 从selenium.webdriver.common.action_chains导入ActionChains 来自selenium.webdriver.common.by导入方式 从selenium.webdriver.support.ui导入webdriverwait 从selenium.webdriver.support导入EC的预期条件 从selenium.webdriver.common.keys导入密钥 导入登录数据 #import tes 将speech_recognition导入为sr 导入pyttsx3

r = sr.Recognizer()

# initialisation
engine = pyttsx3.init()

# testing
engine.say("Hello!What do you want me to do?")
#engine.say("Thank you,Geeksforgeeks")
engine.runAndWait()
# Initialize recognizer class (for recognizing the speech)


# Reading Microphone as source
# listening the speech and store in audio_text variable
with sr.Microphone() as source:
    print("Talk")
    audio_text = r.listen(source)
    print("Time over,thanks")
    # recoginize_() method will throw a request error if the API is unreachable,hence using exception handling

    try:
        # using google speech recognition
        text= r.recognize_google(audio_text)
        print("Text: " +text)
    except:
        print("Sorry,I did not get that")



# opening the browser.....................


options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
driver = webdriver.Chrome()
action = ActionChains(driver)
time.sleep(1)

driver.get('http://www.amazon.in')
try:
    firstLevelMenu =webdriverwait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR,"#nav-link-accountList")))
    action = ActionChains(driver)
    action.move_to_element(firstLevelMenu).perform()
except Exception as e:
    print(e)

secondLevelMenu = driver.find_element_by_xpath('//*[@id="nav-flyout-ya-signin"]/a/span')
secondLevelMenu.click()
time.sleep(3)

signinelement = driver.find_element_by_xpath('//*[@id="ap_email"]')
signinelement.send_keys(logindata.USERNAME)
time.sleep(3)

cont = driver.find_element_by_xpath('//*[@id="continue"]')
cont.click()
time.sleep(3)

passwordelement = driver.find_element_by_xpath('//*[@id="ap_password"]')
passwordelement.send_keys(logindata.PASSWORD)
time.sleep(3)

login = driver.find_element_by_xpath('//*[@id="signInSubmit"]')
login.click()
time.sleep(3)


#..............this is  for searching......................


searchbar = driver.find_element_by_xpath('//*[@id="twotabsearchtextBox"]')
searchbar.send_keys(tes.text)
searchbar.send_keys(Keys.ENTER)
time.sleep(3) 

'''

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...