Description: Use audio to help users learn basic phrases in a new language. Features: Display text for phrases, add audio playback for pronunciation, and track user progress.
Drop files here
or click to upload
import streamlit as st
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import DeclarativeBase, Session
class Base(DeclarativeBase):
pass
class UserProgress(Base):
__tablename__ = 'user_progress'
id = Column(Integer, primary_key=True)
phrase = Column(String)
learned = Column(Integer, default=0)
engine = create_engine("sqlite:///progress.sqlite")
Base.metadata.create_all(bind=engine)
phrases = [
{'phrase': 'Hello', 'audio': 'audio/hello.mp3'},
{'phrase': 'Thank you', 'audio': 'audio/thank_you.mp3'},
{'phrase': 'Goodbye', 'audio': 'audio/goodbye.mp3'},
]
st.title('Language Learning with Audio')
if 'user_progress' not in st.session_state:
st.session_state.user_progress = {phrase['phrase']: 0 for phrase in phrases}
for phrase in phrases:
st.write(phrase['phrase'])
st.audio(phrase['audio'])
if st.button(f'Learnt: {phrase[
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?