How with google text-to-speech (gTTS) I can save to the MP3 file 2 Variables with different languages? (Python)
See original GitHub issueHow with google text-to-speech I can save to the MP3 file 2 Variables with different languages? Please help me. Everywhere is written only for 1 language. This is my code:
from gtts import gTTS
import os
import pickle
import pandas as pd
frame = pd.read_csv('file.csv', header=0, sep = '\t', encoding='cp1251')
print(frame)
text1 = list()
text2 = list()
for a, b in zip(frame['English'], frame['Русский']):
text1.append(a)
text2.append(b)
print(text1,
text2)
text1 = str(text1)
text2 = str(text2)
tts1 = gTTS(text=text1, lang='en')
tts2 = gTTS(text=text2, lang='ru')
# tts2.save("from_file.mp3") it work just for one Variable!
with open('from_file.mp3', 'wb') as pickle_file:
pickle.dump([tts1, tts2], pickle_file)
# with pickle it doesn't work!
os.system("from_file.mp3")
file content:
English Русский
tell говорить
fly летать
sit сидеть
act действовать
As a solution: I can loop every word with gTTS and add in mp3 file, but how can I add data in mp3 without delete past data ?? I want to create an audio dictionary.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How with google text-to-speech (gTTS) I can ... - Stack Overflow
How with google text-to-speech (gTTS) I can save to the MP3 file 2 Variables with different languages? (Python) Save this question. Show ...
Read more >Python - Transform text in mp3 with Google Text to Speech gTTS
It is possible to convert a text into an audio file in mp3 format with a simple script.My blogs about Python : ...
Read more >How to get started with Google Text-to-Speech using Python
We will import the gTTS library from the gtts module which can be used for speech translation. The text variable is a string...
Read more >Using the Text-to-Speech API with Python - Google Codelabs
The Text-to-Speech API enables developers to generate human-like speech. The API converts text into audio formats such as WAV, MP3, or Ogg Opus....
Read more >Make Your Python Program Speak! - Level Up Coding
text = "Hello World!" tts = gTTS(text, slow=False, pre_processor_funcs = [abbreviations, end_of_line]) # Save the audio in a mp3 file tts ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should help you get two languages in one mp3 file.
You need to use for . You will have 1 mp3 file with this sequence of words --> ‘en’, ‘zh-tw’, ‘en’, ‘zh-tw’… “File.mp3” should be in the project directory or specify the full path to the file.
You can use:
if you want to play slowly. You can also use Pandas if you want to take the words from a file (.txt , .csv …)