File size: 853 Bytes
c7468f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# app.py
import gradio as gr
import torch
from TTS.api import TTS

# Load Sinhala TTS model from Hugging Face
tts = TTS(model_name="bhasha/sinhala-tts", progress_bar=False, gpu=False)

def speak_sinhala(text):
    # Generate speech and return audio path
    output_path = "output.wav"
    tts.tts_to_file(text=text, file_path=output_path)
    return output_path

# Sinhala UI Labels
gr.Interface(
    fn=speak_sinhala,
    inputs=gr.Textbox(label="සිංහල වාක්‍යය ඇතුළත් කරන්න"),
    outputs=gr.Audio(type="filepath", label="ඔබේ හඬ"),
    title="සිංහල වචන → හඬ",
    description="ඔබගේ සිංහල වචන කීපයක් ඇතුළත් කරන්න. මෙම යෙදුම ඒවා හඬක් ලෙස නිකුත් කරයි."
).launch()