from gtts import gTTS from IPython.display import Audio from io import BytesIO
Get user input
text = input("Enter the text you want to convert to speech: ")
Create a gTTS object and get audio as bytes
tts = gTTS(text) audio_bytes = BytesIO() tts.write_to_fp(audio_bytes)
from IPython.display import Audio
Replace 'your_audio_file.mp3' with the name of your audio file
audio_path = '/content/welcome.mp3'
Play the audio
Audio(audio_path)