Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Install the necessary libraries
|
| 2 |
+
# !pip install gtts gradio
|
| 3 |
+
|
| 4 |
+
from gtts import gTTS
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
# Function to convert text to audio
|
| 8 |
+
def text_to_audio(mytext):
|
| 9 |
+
# Create a gTTS object with Bulgarian language
|
| 10 |
+
tts = gTTS(text=mytext, lang='bg')
|
| 11 |
+
# Save the audio file
|
| 12 |
+
filename = "output.mp3"
|
| 13 |
+
tts.save(filename)
|
| 14 |
+
return filename
|
| 15 |
+
|
| 16 |
+
# Gradio interface
|
| 17 |
+
def gradio_interface(text):
|
| 18 |
+
audio_file = text_to_audio(text)
|
| 19 |
+
return audio_file
|
| 20 |
+
|
| 21 |
+
# Create a Gradio interface
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=gradio_interface,
|
| 24 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
| 25 |
+
outputs=gr.Audio(type="filepath"),
|
| 26 |
+
title="Text to Speech Application (Bulgarian audio)",
|
| 27 |
+
description="Type your text and to generate the corresponding audio in Bulgarian."
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# Launch the interface
|
| 31 |
+
iface.launch(share=True)
|