-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add firestore_sdk ad session_manager * save user chats on firestore * pass down session_id for a deterministic workflow * handle conversion of chat object to/fro a dict * remove references to langchain * reuse a previously downloaded audiofile if it's processable * render audiocast metdata on share page * cleanup * temp remove audio_enchancement * sanitize audiocast transcript * add elevenlabs client * add __text_to_speech_elevenlabs; cleanup * use dry in text_to_speech * only lint on python versions 3.11 and 3.12 * add write permission to deploy job for marocchino/sticky-pull-request-comment * use eleven_multilingual_v2 model for improved stability, accuracy and quality * Refactor audiocast page to include waveform visualization * put waveform viz in an expander * cleanup * move download_waveform_video internal to render_waveform * allow toggling waveform visualizer * save waveform to gcs * reshuffle dependencies in requirements.txt * add pycairo to deps * fix reference to pyproject.toml * add deps for cairo library
- Loading branch information
1 parent
e8b0f4f
commit 8664cbb
Showing
9 changed files
with
256 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import subprocess | ||
|
||
|
||
def create_video_from_audio(audio_path: str, image_path: str, output_path: str): | ||
"""Create a video with audio and spectrogram overlay.""" | ||
cmd = [ | ||
"ffmpeg", | ||
"-y", | ||
"-loop", | ||
"1", | ||
"-i", | ||
image_path, | ||
"-i", | ||
audio_path, | ||
"-c:v", | ||
"libx264", | ||
"-tune", | ||
"stillimage", | ||
"-c:a", | ||
"aac", | ||
"-b:a", | ||
"192k", | ||
"-pix_fmt", | ||
"yuv420p", | ||
"-shortest", | ||
output_path, | ||
] | ||
|
||
try: | ||
subprocess.run(cmd, check=True) | ||
os.remove(image_path) # Clean up temporary spectrogram | ||
return True | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error during video creation: {str(e)}") | ||
return False | ||
except Exception as e: | ||
print(f"Error during video creation: {str(e)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import re | ||
from pathlib import Path | ||
from typing import TypedDict | ||
|
||
import streamlit as st | ||
|
||
from src.env_var import APP_URL | ||
from src.utils.waveform_utils import render_waveform | ||
|
||
|
||
def navigate_to_home(): | ||
main_script = str(Path(__file__).parent.parent / "app.py") | ||
st.switch_page(main_script) | ||
|
||
|
||
def parse_ai_script(ai_script: str): | ||
matches = re.findall(r"<(Speaker\d+)>(.*?)</Speaker\d+>", ai_script, re.DOTALL) | ||
return "\n\n".join([f"**{speaker}**: {content}" for speaker, content in matches]) | ||
|
||
|
||
class GenerateAudiocastDict(TypedDict): | ||
url: str | ||
script: str | ||
source_content: str | ||
created_at: str | None | ||
|
||
|
||
def render_audiocast_handler(session_id: str, audiocast: GenerateAudiocastDict): | ||
# Audio player | ||
st.audio(audiocast["url"]) | ||
|
||
st.markdown("---") | ||
|
||
col1, _ = st.columns([4, 1]) | ||
with col1: | ||
|
||
def toggle_show_waveform(): | ||
st.session_state.show_waveform = not st.session_state.get("show_waveform") | ||
|
||
button_label = ( | ||
"Hide Waveform Visualization" | ||
if st.session_state.get("show_waveform") | ||
else "Show Waveform Visualization" | ||
) | ||
|
||
st.button( | ||
button_label, | ||
on_click=toggle_show_waveform, | ||
use_container_width=True, | ||
) | ||
|
||
if st.session_state.get("show_waveform"): | ||
try: | ||
render_waveform(session_id, audiocast["url"]) | ||
except Exception as e: | ||
st.error(f"Error rendering waveform: {str(e)}") | ||
|
||
st.markdown("---") | ||
|
||
# Transcript | ||
with st.expander("Show Transcript"): | ||
st.markdown(parse_ai_script(audiocast["script"])) | ||
|
||
st.markdown("---") | ||
|
||
# Metadata | ||
st.sidebar.subheader("Audiocast Source") | ||
st.sidebar.markdown(audiocast["source_content"]) | ||
|
||
share_url = f"{APP_URL}/audiocast?session_id={session_id}" | ||
st.text_input("Share this audiocast:", share_url) | ||
|
||
return share_url |
Oops, something went wrong.