Spaces:
Running
Running
File size: 1,083 Bytes
8582fd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
from TTS import TTS
import transformers
def text_to_speech(text, choice):
TTS(text, choice)
return "Output/base-TTS.wav"
def convert_to_speech(text, choice):
if text:
output_file = text_to_speech(text, choice=choice)
with open(output_file, 'rb') as audio_file:
audio_bytes = audio_file.read()
return (audio_bytes, "Conversion successful!")
else:
return (None, "Please enter some text to convert.")
def app(text, choice):
audio, message = convert_to_speech(text, choice)
return audio, message
iface = gr.Interface(
fn=app,
inputs=[
gr.Textbox(lines=2, placeholder="Enter text here...", label="Text Input"),
gr.Radio(choices=["Female", "Male"], label="Speaker")
],
outputs=[
gr.Audio(type="filepath", label="Output Audio"),
gr.Textbox(label="Message")
],
title="Stars AI Text to Speech Conversion App",
description="Convert text to speech with a female or male voice."
)
iface.launch(share=True)
|