-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudBookMkr.py
More file actions
executable file
·26 lines (22 loc) · 874 Bytes
/
AudBookMkr.py
File metadata and controls
executable file
·26 lines (22 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
# Import the Gtts module for text
# to speech conversion
from gtts import gTTS
# import Os module to start the audio file
import os
from pathlib import Path
def inputManager():
while 1:
userInput = input("Hello, I'm here to help you to convert a text files to audio files. \n Please tell me the path of your File: ")
my_file = Path(userInput)
if my_file.is_file():
userInput2 = input("Where do you want to save the file? [/path/Filename] \n Disclaimer: Ending is always mp3 ")
AudBookMkr(userInput, userInput2+".mp3")
break
else:
print("no such path found, please try again")
def AudBookMkr(file, audio):
with open(file, "r") as fh:
output = gTTS(text=fh.read().replace("\n", " "), lang='en', slow=False)
output.save(audio)
inputManager()