From 6479dc202dfd407f670ec8bc33ca8143ebf579bb Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 12 Dec 2020 17:12:17 +0530 Subject: [PATCH] wip tts --- SimonSays.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SimonSays.py diff --git a/SimonSays.py b/SimonSays.py new file mode 100644 index 0000000..d4e6a1e --- /dev/null +++ b/SimonSays.py @@ -0,0 +1,48 @@ +""" +Simon Says +""" + +from selenium import webdriver +from selenium.webdriver.support.ui import Select +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +base_url = "https://azure.microsoft.com/en-in/services/cognitive-services/text-to-speech/" + +fname = "./archive-daily-dose/11 November, 2020.html" +text = open(fname,'rb').read().decode('utf-8') +#text = "Hakuna Matata fjbsdf sd fsdf sdf s df sd fs df" + +def strip_html(text): + import re + p = re.compile(r'<.*?>') + return p.sub('',text) +#print(text) + +text = strip_html(text) + + +driver = webdriver.Chrome() +driver.get(base_url) + +WebDriverWait(driver, 5).until( + EC.presence_of_element_located((By.ID, "languageselect")) +) + +langsel = driver.find_element_by_id('languageselect') +select = Select(langsel) +select.select_by_visible_text("English (UK)") + +voicesel = driver.find_element_by_id('voiceselect') +select = Select(voicesel) +select.select_by_visible_text("Mia (Neural)") + +textselect = driver.find_element_by_id('ttstext') +textselect.clear() +textselect.send_keys(text) + +play = driver.find_element_by_id('playbtn') +play.click() + +#river.quit()