nidhaloff / deep-translator

A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.
https://deep-translator.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
1.61k stars 186 forks source link

Text to speech for Google Translate and other translators that support the feature #221

Closed JohnnyRacer closed 1 year ago

JohnnyRacer commented 1 year ago

Hello, is there a way to get the text to speech narration for a translation using Google Translate or other translators that support text to speech? There doesn't seem to be an issue that mentions this that I could find.

nidhaloff commented 1 year ago

Can you explain a concrete case here? You want text to speech? So you want deep-translator to output a speech a.k.a audio file?

JohnnyRacer commented 1 year ago

Yes having the option to get the text to speech to an audio file since Google Translate already has this feature.
image If you click on the speaker icon it will narrate the translation.

nidhaloff commented 1 year ago

I see. This is not possible for deep-translator since it uses web scraping to determine the translation and not the google api itself. However, this could be achieved with any library for text-to-speech, for example this one or even better the gtts library

Just take a look at that example. Simply give the output translation from deep-translator to the library and let it handle the conversion for you. With that said, I won't consider this feature for deep-translator since the scope is different here (Well maybe using optional dependencies, then I would consider it)