Created
January 7, 2021 16:44
-
-
Save theshahzaibc/c1a3905e63941ed07c368e7d4884767d to your computer and use it in GitHub Desktop.
This file contains 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
def audioToText(audioFile): | |
""" Converting audio mp3 to text """ | |
driver.execute_script('''window.open("","_blank")''') | |
driver.switch_to.window(driver.window_handles[1]) | |
driver.get(SpeechToTextURL) | |
delay() | |
audioInput = driver.find_element(By.XPATH, '//*[@id="root"]/div/input') | |
# upload file mp3 to input | |
audioInput.send_keys(audioFile) | |
time.sleep(audioToTextDelay) | |
# waiting for conversion to text | |
text = driver.find_element(By.XPATH, '//*[@id="root"]/div/div[7]/div/div/div/span') | |
while text is None: | |
text = driver.find_element(By.XPATH, '//*[@id="root"]/div/div[7]/div/div/div/span') | |
result = text.text # final text after conversion | |
driver.close() | |
driver.switch_to.window(driver.window_handles[0]) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment