Skip to content

Instantly share code, notes, and snippets.

@theshahzaibc
Created January 7, 2021 16:44
Show Gist options
  • Save theshahzaibc/c1a3905e63941ed07c368e7d4884767d to your computer and use it in GitHub Desktop.
Save theshahzaibc/c1a3905e63941ed07c368e7d4884767d to your computer and use it in GitHub Desktop.
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