File size: 658 Bytes
fc1fe4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

def kokoro_tts(text):
    # Initialize the transformers pipeline for text-to-speech
    tts_pipeline = pipeline("text-to-speech", model="kokoro/tts")
    # Generate speech from text
    speech = tts_pipeline(text)
    return speech["waveform"]

# Create a Gradio interface
iface = gr.Interface(
    fn=kokoro_tts,
    inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
    outputs=gr.outputs.Audio(label="Generated Speech"),
    title="Kokoro Text-to-Speech",
    description="A Text-to-Speech app powered by Kokoro and Transformers.js"
)

if __name__ == "__main__":
    iface.launch()