bark / app.py
prakhardoneria's picture
Update app.py
86f73b0 verified
raw
history blame contribute delete
754 Bytes
import gradio as gr
from transformers import pipeline
import scipy.io.wavfile
# Initialize the text-to-speech pipeline
synthesiser = pipeline("text-to-speech", "suno/bark-small")
def text_to_speech(text):
# Generate speech
speech = synthesiser(text, forward_params={"do_sample": True})
# Save to a WAV file
output_file = "bark_out.wav"
scipy.io.wavfile.write(output_file, rate=speech["sampling_rate"], data=speech["audio"])
return output_file
# Create Gradio interface
demo = gr.Interface(
fn=text_to_speech,
inputs=gr.Textbox(label="Enter Text", placeholder="Type something..."),
outputs=gr.Audio(label="Generated Speech", autoplay=True)
)
# Launch the app
#if __name__ == "__main__":
demo.launch()