Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from utils import * | |
| import io | |
| # Customizing the appearance | |
| st.markdown( | |
| """ | |
| <style> | |
| .stApp { | |
| background-color: #f8f9fa; | |
| color: #333333; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| } | |
| .stRadio > div > div { | |
| background-color: #006699 !important; | |
| color: white !important; | |
| } | |
| .stButton>button { | |
| background-color: #006699; | |
| color: white; | |
| font-size: 16px; | |
| font-weight: bold; | |
| border-radius: 5px; | |
| padding: 10px 20px; | |
| } | |
| .footer { | |
| background-color: #f0f2f6; | |
| padding: 10px; | |
| color: #666666; | |
| font-size: 14px; | |
| text-align: center; | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| def main(): | |
| st.title("GenAI Speech-Text Transcriber") | |
| mode = st.radio('Choose Mode', ('Speech to Text', 'Text to Speech'), key="mode_selection") | |
| if mode == 'Text to Speech': | |
| st.subheader('Convert Text to Speech') | |
| input_text = st.text_area("Enter the text here") | |
| if st.button("Generate Audio", key="generate_audio") and input_text: | |
| response = text_to_speech(input_text) | |
| if response: | |
| st.audio(io.BytesIO(response.content), format='audio/mp3') | |
| elif mode == 'Speech to Text': | |
| st.subheader('Convert Speech to Text') | |
| audio_uploaded = st.file_uploader("Upload your audio file", type=['mp3', 'wav']) | |
| if st.button("Generate Transcript", key="generate_transcript") and audio_uploaded: | |
| text = audio_to_text(audio_uploaded) | |
| st.write(text) | |
| st.markdown("<p class='footer'>Powered by GenAI</p>", unsafe_allow_html=True) | |
| if __name__ == '__main__': | |
| main() |