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()