hivecorp commited on
Commit
fc1fe4c
·
verified ·
1 Parent(s): 6055eba

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ def kokoro_tts(text):
5
+ # Initialize the transformers pipeline for text-to-speech
6
+ tts_pipeline = pipeline("text-to-speech", model="kokoro/tts")
7
+ # Generate speech from text
8
+ speech = tts_pipeline(text)
9
+ return speech["waveform"]
10
+
11
+ # Create a Gradio interface
12
+ iface = gr.Interface(
13
+ fn=kokoro_tts,
14
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
15
+ outputs=gr.outputs.Audio(label="Generated Speech"),
16
+ title="Kokoro Text-to-Speech",
17
+ description="A Text-to-Speech app powered by Kokoro and Transformers.js"
18
+ )
19
+
20
+ if __name__ == "__main__":
21
+ iface.launch()