Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I want to download and save the audio of the link in python

I want to download and save the audio of the link in python.
How should I write it in beautifulsoup or selenium?
I don’t know the answer.

Link

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to download something with Python, there is no reason to use either Selenium or BeautifulSoup. Instead, consider using the requests library:

pip install requests

And download the mp3 like so:

import requests

response = requests.get("https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=how%27s%20the%20weather%20today?")
open("file.mp3", "wb").write(response.content)

This will download the audio to a file called file.mp3 in your local directory.

You could also use other alternatrives such as wget and urllib. You could even download the file by running a simple curl command:

curl -o file.mp3 https://translate.google.com/translate_tts\?ie\=UTF-8\&client\=tw-ob\&tl\=en\&q\=how%27s%20the%20weather%20today\?
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading