devrishi commited on
Commit
465fd1a
Β·
verified Β·
1 Parent(s): f0f3975

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +4 -0
  2. app.py +29 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  ---
2
  title: Text To Speech
3
  emoji: πŸŒ–
 
1
+ # Story to Speech Converter
2
+
3
+ This app allows users to convert stories into MP3 speech files using Google Text-to-Speech (gTTS). Enter your story and download the resulting audio file.
4
+
5
  ---
6
  title: Text To Speech
7
  emoji: πŸŒ–
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gtts import gTTS
3
+
4
+ # Function to convert text to speech
5
+ def text_to_speech_with_gtts(text, language='hi'):
6
+ try:
7
+ # Generate speech using gTTS
8
+ tts = gTTS(text=text, lang=language, slow=False)
9
+ output_file = "output.mp3"
10
+ tts.save(output_file)
11
+ return output_file # Return the file path for download
12
+ except Exception as e:
13
+ return f"An error occurred: {e}"
14
+
15
+ # Gradio Interface
16
+ iface = gr.Interface(
17
+ fn=text_to_speech_with_gtts,
18
+ inputs=[
19
+ gr.Textbox(lines=15, label="Enter the Full Story", placeholder="Type or paste your story here..."),
20
+ gr.Textbox(label="Language Code (e.g., 'en', 'hi')", value='hi')
21
+ ],
22
+ outputs=gr.File(label="Download MP3"),
23
+ title="Story to Speech Converter",
24
+ description="Convert your story to speech using gTTS. Enter your text and download the MP3 file."
25
+ )
26
+
27
+ # Launch Gradio Interface
28
+ if __name__ == "__main__":
29
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ gtts