dshamika commited on
Commit
c7468f5
·
verified ·
1 Parent(s): 09d9d52

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ import torch
4
+ from TTS.api import TTS
5
+
6
+ # Load Sinhala TTS model from Hugging Face
7
+ tts = TTS(model_name="bhasha/sinhala-tts", progress_bar=False, gpu=False)
8
+
9
+ def speak_sinhala(text):
10
+ # Generate speech and return audio path
11
+ output_path = "output.wav"
12
+ tts.tts_to_file(text=text, file_path=output_path)
13
+ return output_path
14
+
15
+ # Sinhala UI Labels
16
+ gr.Interface(
17
+ fn=speak_sinhala,
18
+ inputs=gr.Textbox(label="සිංහල වාක්‍යය ඇතුළත් කරන්න"),
19
+ outputs=gr.Audio(type="filepath", label="ඔබේ හඬ"),
20
+ title="සිංහල වචන → හඬ",
21
+ description="ඔබගේ සිංහල වචන කීපයක් ඇතුළත් කරන්න. මෙම යෙදුම ඒවා හඬක් ලෙස නිකුත් කරයි."
22
+ ).launch()