arjunbroepic commited on
Commit
eb2daf6
·
verified ·
1 Parent(s): ff46712

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import os
4
+
5
+ def generate_speech(text):
6
+ output_file = "output.wav"
7
+ # Adjust this command based on the binary's usage (e.g., ./moss_nano -t "text" -o output.wav)
8
+ # Check the repo's README for exact CLI arguments
9
+ cmd = ["./moss_nano", "--text", text, "--output", output_file]
10
+
11
+ try:
12
+ subprocess.run(cmd, check=True)
13
+ if os.path.exists(output_file):
14
+ return output_file
15
+ else:
16
+ return None
17
+ except Exception as e:
18
+ return f"Error: {str(e)}"
19
+
20
+ demo = gr.Interface(
21
+ fn=generate_speech,
22
+ inputs=gr.Textbox(label="Enter Text", placeholder="Hello, I am MossTTS Nano."),
23
+ outputs=gr.Audio(label="Generated Speech"),
24
+ title="MossTTS-Nano (Pure C Optimized)",
25
+ description="This space runs the ultra-fast C implementation of MossTTS-Nano."
26
+ )
27
+
28
+ demo.launch()