alexlaverty / python-reddit-youtube-bot

Automated Reddit Youtube Video Bot
https://www.youtube.com/channel/UCzIwW92D_rM5_yvWBsquSbw
78 stars 17 forks source link

Could you help with this error? #56

Open reineto opened 1 year ago

reineto commented 1 year ago

aaaaa

alexlaverty commented 1 year ago

Is this the reddit post you were trying to convert? : https://www.reddit.com/r/desabafos/comments/123n2m1/minha_namorada_mudou_comigo_do_nada_oq_fazer_me/

I think the text to speech engine is not able to convert the portuguese characters.. : (

alexlaverty commented 1 year ago

ok I spoke to ChatGPT and apparently it can be done, I will try work this into the code

write a python script that will convert this text to portuguese speech : "Você não vai descobrir enquanto não falar com ela. Qualquer coisa diferente disso é invenção da sua cabeça."

To convert the given text to Portuguese speech using Python, you can use the gTTS (Google Text-to-Speech) library. Here's the code to achieve this:

python
Copy code
from gtts import gTTS
import os

# Set the text you want to convert to speech
text = "Você não vai descobrir enquanto não falar com ela. Qualquer coisa diferente disso é invenção da sua cabeça."

# Set the language to Portuguese
language = 'pt'

# Create an instance of gTTS and specify the language
speech = gTTS(text=text, lang=language, slow=False)

# Save the speech as an MP3 file
speech.save("speech.mp3")

# Play the MP3 file
os.system("mpg321 speech.mp3")
The script will create an MP3 file named "speech.mp3" in the same directory as the Python script and play it using the mpg321 player. You can change the filename and player to suit your needs.
alexlaverty commented 1 year ago

I've pushed a commit to allow setting the language for the gTTS voice engine 280df0828945c1716fd75ca7716fcffbdd0f29ea

git pull the latest code, and then in your config/settings.py config file set the following :

voice_engine = "gtts"
gtts_language = 'pt'

example video is here : https://youtu.be/kshKztyAxxg

I don't speak the language so no idea if it's understandable or not, have a look and let me know if makes any sense : )