Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
import soundfile as sf
|
| 4 |
+
from inference import TTSInference
|
| 5 |
+
|
| 6 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 7 |
+
|
| 8 |
+
tts = TTSInference(
|
| 9 |
+
model_path="model.pt",
|
| 10 |
+
tokenizer_path="tts_tokenizer.model",
|
| 11 |
+
device=device
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
def synthesize(text):
|
| 15 |
+
audio = tts.synthesize(text)
|
| 16 |
+
sf.write("output.wav", audio.numpy(), 22050)
|
| 17 |
+
return "output.wav"
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=synthesize,
|
| 21 |
+
inputs=gr.Textbox(label="Enter Text"),
|
| 22 |
+
outputs=gr.Audio(type="filepath"),
|
| 23 |
+
title="Realtime Multilingual TTS",
|
| 24 |
+
description="Frame-Level Positional Encoding Optimized for Conversations"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
iface.launch()
|