mrbeliever commited on
Commit
cba7193
·
verified ·
1 Parent(s): 2de956d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -14
app.py CHANGED
@@ -246,20 +246,26 @@ for voice_name, voice_code in language_dict.items():
246
  language_groups[language] = []
247
  language_groups[language].append(voice_name)
248
 
249
- # CSS for centering elements
250
  st.markdown("""
251
  <style>
252
- .main {
253
- display: flex;
254
- flex-direction: column;
255
- align-items: center;
256
- justify-content: center;
257
- text-align: center;
 
 
 
258
  }
259
  .stButton > button {
260
  display: block;
261
  margin-left: auto;
262
  margin-right: auto;
 
 
 
263
  }
264
  .stAudio {
265
  display: flex;
@@ -269,6 +275,19 @@ st.markdown("""
269
  display: block;
270
  margin-left: auto;
271
  margin-right: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  }
273
  </style>
274
  """, unsafe_allow_html=True)
@@ -281,9 +300,9 @@ async def text_to_speech_edge(text, voice):
281
  return tmp_path
282
 
283
  def main():
284
- # Center the title and description
285
- st.markdown("<h1 style='text-align: center;'>Text-to-Speech Converter</h1>", unsafe_allow_html=True)
286
- st.markdown("<p style='text-align: center;'>Enter text and select a language and voice to generate an MP3 audio file.</p>", unsafe_allow_html=True)
287
 
288
  # Input text area, centered
289
  with st.container():
@@ -298,11 +317,11 @@ def main():
298
  voices = language_groups.get(selected_language, [])
299
  selected_voice = st.selectbox("Select Voice", voices, index=0)
300
 
301
- # Center the button
302
  with st.container():
303
- if st.button("Generate Audio"):
304
  if input_text and selected_voice:
305
- with st.spinner("Generating audio..."):
306
  voice_code = language_dict.get(selected_voice, "en-US-JennyNeural")
307
  try:
308
  loop = asyncio.new_event_loop()
@@ -318,7 +337,8 @@ def main():
318
  label="Download MP3",
319
  data=file,
320
  file_name="output.mp3",
321
- mime="audio/mp3"
 
322
  )
323
 
324
  # Clean up temporary file
 
246
  language_groups[language] = []
247
  language_groups[language].append(voice_name)
248
 
249
+ # CSS for centering elements and dark styling
250
  st.markdown("""
251
  <style>
252
+ .main {
253
+ display: flex;
254
+ flex-direction: column;
255
+ align-items: center;
256
+ justify-content: center;
257
+ text-align: center;
258
+ background-color: #000000;
259
+ padding: 20px;
260
+ border-radius: 8px;
261
  }
262
  .stButton > button {
263
  display: block;
264
  margin-left: auto;
265
  margin-right: auto;
266
+ background-color: #1f77b4;
267
+ color: #ffffff;
268
+ border-radius: 8px;
269
  }
270
  .stAudio {
271
  display: flex;
 
275
  display: block;
276
  margin-left: auto;
277
  margin-right: auto;
278
+ background-color: #1f77b4;
279
+ color: #ffffff;
280
+ border-radius: 8px;
281
+ }
282
+ .stTextArea > div > div > textarea {
283
+ background-color: #262730;
284
+ color: #ffffff;
285
+ border-radius: 8px;
286
+ }
287
+ .stSelectbox > div > div > select {
288
+ background-color: #262730;
289
+ color: #ffffff;
290
+ border-radius: 8px;
291
  }
292
  </style>
293
  """, unsafe_allow_html=True)
 
300
  return tmp_path
301
 
302
  def main():
303
+ # Center the title and description with dark styling
304
+ st.markdown("<h1 style='text-align: center; color: #ffffff;'>Text-to-Speech Converter</h1>", unsafe_allow_html=True)
305
+ st.markdown("<p style='text-align: center; color: #ffffff;'>Enter text and select a language and voice to generate an MP3 audio file.</p>", unsafe_allow_html=True)
306
 
307
  # Input text area, centered
308
  with st.container():
 
317
  voices = language_groups.get(selected_language, [])
318
  selected_voice = st.selectbox("Select Voice", voices, index=0)
319
 
320
+ # Center the button with container width
321
  with st.container():
322
+ if st.button("Generate Audio", use_container_width=True):
323
  if input_text and selected_voice:
324
+ with st.spinner("Generating audio... Please wait!"):
325
  voice_code = language_dict.get(selected_voice, "en-US-JennyNeural")
326
  try:
327
  loop = asyncio.new_event_loop()
 
337
  label="Download MP3",
338
  data=file,
339
  file_name="output.mp3",
340
+ mime="audio/mp3",
341
+ use_container_width=True
342
  )
343
 
344
  # Clean up temporary file