File size: 710 Bytes
6d8045f
b8743e6
744d347
6d8045f
c9239bf
 
 
744d347
c9239bf
744d347
 
c9239bf
6d8045f
 
c9239bf
 
24cd0ad
 
c9239bf
 
 
 
29050a3
c9239bf
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
import gradio as gr
from gtts import gTTS
import os

def text_to_speech(text):
    if not text.strip():
        return None
    tts = gTTS(text=text, lang="en")  # চাইলে "bn" দিলে বাংলা হবে
    file_path = "output.mp3"
    tts.save(file_path)
    
    return file_path


with gr.Blocks() as demo:
    gr.Markdown("## 🗣️ Text to Speech App")
    text_input = gr.Textbox(label="Enter your text", placeholder="Type something...")
    output_audio = gr.Audio(label="Generated Voice", type="filepath")
    submit_btn = gr.Button("🔊 Submit")
    
    submit_btn.click(fn=text_to_speech, inputs=text_input, outputs=output_audio)

demo.launch(show_error=True)