Chelsea / app.py
CineAI's picture
4172637469634d6f6e6b6579733a33302e30372e3234
e294914
raw
history blame
4.33 kB
# version - ArcticMonkeys:30.07.24
# python core libraries
import psutil
# streamlit
import streamlit as st
# components from other authors
from streamlit_mic_recorder import mic_recorder
# core modules
from audio_processing.A2T import A2T
from audio_processing.T2A import T2A
from llm.utils.chat import Conversation
# utils modules
from utils.keywords import keywords
from utils.prompt_toggle import select_prompt, load_prompts
from utils.documentation import Documentation
# TODO:
# * Зробити в utils можливість для використання різних промптів -> Done
# * Додати як робив на HF хто на фото -> agent
# * Додати можливіть малюнками вирішувати мат проблеми -> agent
# * Додати моливість створювати/редагувати докменти(pdf, docx) -> agent
prompts = load_prompts()
doc = Documentation()
chat = Conversation()
t2a = T2A()
def main():
try:
mic = mic_recorder(start_prompt="Record", stop_prompt="Stop", just_once=True, use_container_width=True)
if mic is not None:
a2t = A2T(mic["bytes"])
text = a2t.predict()
print(f"Text: {text}")
prompt = select_prompt(input_text=text, prompts=prompts, keywords=keywords)
print(f"Prompt:\n{prompt}")
response = chat.chatting(prompt=prompt if prompt is not None else text)
t2a.autoplay(response)
if response:
st.markdown(f"Your input: {prompt}")
st.markdown(f"Chelsea response: {response}")
prompt = None
response = None
except Exception as e:
print(f"An error occurred in main finction, reasone is: {e}")
doc.execution()
if __name__ == "__main__":
print(f"Total Memory: {psutil.virtual_memory().total / (1024**3):.2f} GB")
print(f"Available Memory: {psutil.virtual_memory().available / (1024**3):.2f} GB")
print(f"CPU Cores: {psutil.cpu_count()}")
print(f"CPU Usage: {psutil.cpu_percent()}%")
main()
footer="""
<style>
/* Common styles for the footer */
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60px; /* Set a fixed height for consistency */
font-size: 14px; /* Adjust font size for readability */
text-align: center;
padding: 15px 0; /* Reduced padding */
transition: color 0.3s, background-color 0.3s;
}
.footer p {
margin: 0; /* Remove default margins */
font-size: 18px; /* Adjust font size as needed */
}
a:link, a:visited {
text-decoration: dotted;
color: inherit; /* Use current text color */
}
a:hover, a:active {
background: linear-gradient(to right, #ffe44d, #ffdd1a, #ffd700, #ffd900);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
}
.footer a:hover {
color: #ff4500; /* Different hover color */
}
/* Light mode styles */
@media (prefers-color-scheme: light) {
a:link, a:visited {
color: #0056b3; /* Blue color for links */
}
.footer a:hover {
color: #ff4500; /* Hover color for light mode */
}
}
/* Dark mode styles */
@media (prefers-color-scheme: dark) {
a:link, a:visited {
color: #ffd700; /* Gold color for links in dark mode */
}
.footer a:hover {
color: #ffa500; /* Hover color for dark mode */
}
}
</style>
<div class="footer">
<p>Please support the project on <a href="https://buymeacoffee.com/cineai" target="_blank">Buy Me a Coffee</a></p>
</div>
"""
st.markdown(footer,unsafe_allow_html=True)