Spaces:
Running
Running
| 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) | |