Skip to content

Instantly share code, notes, and snippets.

@asadamatic
Created March 19, 2020 11:01
Show Gist options
  • Save asadamatic/6ec460a366094517bcd3263c45a65cde to your computer and use it in GitHub Desktop.
Save asadamatic/6ec460a366094517bcd3263c45a65cde to your computer and use it in GitHub Desktop.
A python program that reads text from a file and converts it to audio, saves it and plays it using default audio player.
from gtts import gTTS
import os
with open('message.txt') as file:
message = file.read()
output = gTTS(text = message, lang = 'hi', slow = False)
output.save('messageFromFile.mp3')
os.system('start messageFromFile.mp3')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment