Skip to content

Commit bfdc670

Browse files
author
Lucas Ayres
committed
Add tool for convert text to speech using google translate
1 parent ca33256 commit bfdc670

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tools/text_to_speech_online.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- coding: utf-8 -*-
2+
from gtts import gTTS
3+
4+
5+
def text_to_speech_online(text, lang='en'):
6+
"""Convert text to speech using Google Translate’s and save in mp3. Need an internet connection.
7+
8+
Args:
9+
text (str): Text.
10+
lang (str): Language (Ex: pt-br).
11+
12+
"""
13+
tts = gTTS(text=text, lang=lang)
14+
tts.save("sound.mp3")

0 commit comments

Comments
 (0)