Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,10 @@ import plotly.graph_objects as go
|
|
| 6 |
from datetime import datetime, timedelta, date
|
| 7 |
import requests
|
| 8 |
import google.generativeai as genai
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Constants
|
| 11 |
ENGINEER_SALARY = 10000 # Monthly cost per engineer ($120K/year)
|
|
@@ -25,7 +29,7 @@ if 'chat_history' not in st.session_state:
|
|
| 25 |
]
|
| 26 |
|
| 27 |
# Setup page config and styling
|
| 28 |
-
st.set_page_config(page_title="
|
| 29 |
|
| 30 |
# Apply custom styling
|
| 31 |
st.markdown("""
|
|
@@ -90,43 +94,25 @@ def autoplay_audio(audio_content):
|
|
| 90 |
st.markdown(md, unsafe_allow_html=True)
|
| 91 |
|
| 92 |
def generate_voice_response(text, simulate=False):
|
| 93 |
-
"""Generate voice response using
|
| 94 |
if simulate:
|
| 95 |
return None
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
"model_id": "eleven_monolingual_v1",
|
| 113 |
-
"voice_settings": {
|
| 114 |
-
"stability": 0.5,
|
| 115 |
-
"similarity_boost": 0.5
|
| 116 |
-
}
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
response = requests.post(url, json=data, headers=headers)
|
| 120 |
-
|
| 121 |
-
if response.status_code == 200:
|
| 122 |
-
return response.content
|
| 123 |
-
else:
|
| 124 |
-
st.error(f"Error with ElevenLabs API: {response.status_code}")
|
| 125 |
-
return None
|
| 126 |
-
|
| 127 |
-
except Exception as e:
|
| 128 |
-
st.error(f"Error generating voice response: {e}")
|
| 129 |
-
return None
|
| 130 |
|
| 131 |
|
| 132 |
# Utility Functions
|
|
|
|
| 6 |
from datetime import datetime, timedelta, date
|
| 7 |
import requests
|
| 8 |
import google.generativeai as genai
|
| 9 |
+
pip install gtts
|
| 10 |
+
from gtts import gTTS
|
| 11 |
+
import io
|
| 12 |
+
import streamlit as st
|
| 13 |
|
| 14 |
# Constants
|
| 15 |
ENGINEER_SALARY = 10000 # Monthly cost per engineer ($120K/year)
|
|
|
|
| 29 |
]
|
| 30 |
|
| 31 |
# Setup page config and styling
|
| 32 |
+
st.set_page_config(page_title="Money Minds Pilot", page_icon="💰", layout="wide")
|
| 33 |
|
| 34 |
# Apply custom styling
|
| 35 |
st.markdown("""
|
|
|
|
| 94 |
st.markdown(md, unsafe_allow_html=True)
|
| 95 |
|
| 96 |
def generate_voice_response(text, simulate=False):
|
| 97 |
+
"""Generate voice response using gTTS"""
|
| 98 |
if simulate:
|
| 99 |
return None
|
| 100 |
+
|
| 101 |
+
try:
|
| 102 |
+
# Create a gTTS object
|
| 103 |
+
tts = gTTS(text=text, lang='en')
|
| 104 |
+
|
| 105 |
+
# Save to a bytes buffer
|
| 106 |
+
mp3_fp = io.BytesIO()
|
| 107 |
+
tts.write_to_fp(mp3_fp)
|
| 108 |
+
mp3_fp.seek(0)
|
| 109 |
+
|
| 110 |
+
return mp3_fp.getvalue()
|
| 111 |
+
|
| 112 |
+
except Exception as e:
|
| 113 |
+
st.error(f"Error generating voice response: {e}")
|
| 114 |
+
return None
|
| 115 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
# Utility Functions
|