Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tempfile
|
3 |
+
from ttsmms import TTS
|
4 |
+
import soundfile as sf
|
5 |
+
|
6 |
+
tts = TTS("data/ory")
|
7 |
+
|
8 |
+
def generate_audio(text):
|
9 |
+
wav = tts.synthesis(text)
|
10 |
+
audio_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False)
|
11 |
+
audio_path = audio_file.name
|
12 |
+
sf.write(audio_path, wav["x"], wav["sampling_rate"])
|
13 |
+
return audio_path
|
14 |
+
|
15 |
+
inputs = gr.Textbox(label="Input", max_lines=3)
|
16 |
+
outputs = gr.Audio(label="Output")
|
17 |
+
|
18 |
+
title = "Text-to-Speech App"
|
19 |
+
description = "Enter your text and generate audio."
|
20 |
+
|
21 |
+
gr.Interface(fn=generate_audio, inputs=inputs, outputs=outputs, title=title, description=description).launch(share=True)
|