Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add audiocast share page #3

Merged
merged 20 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions pages/audiocast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import asyncio
from pathlib import Path

import streamlit as st

from src.utils.main_utils import get_audiocast_uri


def navigate_to_home():
main_script = str(Path(__file__).parent.parent / "app.py")
st.switch_page(main_script)


async def render_audiocast_page():
st.set_page_config(page_title="Audiora | Share Page", page_icon="🎧")

audiocast_id = st.query_params.get("uuid")

if audiocast_id:
# Display audiocast content
st.title("🎧 Audiocast Player")
st.write(f"Playing audiocast: {audiocast_id}")

try:
with st.spinner("Loading audiocast..."):
audio_path = get_audiocast_uri(audiocast_id)
st.audio(audio_path)

# TODO: Fetch audiocast metadata from the database
st.subheader("Audiocast Details")
st.write("Created: 2024-03-20")

except Exception as e:
st.error(f"Error loading audiocast: {str(e)}")
else:
st.warning(
"Audiocast ID is missing in the URL. Expected URL format: ?uuid=your-audiocast-id"
)

st.markdown("---")

cola, _ = st.columns([3, 5])
with cola:
if st.button("← Back to Home", use_container_width=True):
navigate_to_home()


if __name__ == "__main__":
asyncio.run(render_audiocast_page())
5 changes: 3 additions & 2 deletions src/utils/main_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ async def generate_audiocast(request: GenerateAudioCastRequest):
return response.model_dump()


async def get_audiocast_uri(uuid: str):
def get_audiocast_uri(uuid: str):
"""
Get the URI for the audiocast
"""
storage_manager = StorageManager()
return storage_manager.download_from_gcs(uuid)
filepath = storage_manager.download_from_gcs(uuid)
return filepath
2 changes: 1 addition & 1 deletion src/utils/render_audiocast.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def render_audiocast():
st.sidebar.subheader("Audiocast Source")
st.sidebar.markdown(current_audiocast["source_content"])

share_url = f"{APP_URL}/audiocast/{current_audiocast['uuid']}"
share_url = f"{APP_URL}/audiocast?uuid={current_audiocast['uuid']}"
st.text_input("Share this audiocast:", share_url)

share_col, restart_row = st.columns(2, vertical_alignment="bottom")
Expand Down
Loading