import streamlit as st from audio_recorder_streamlit import audio_recorder from groq_models import create_groq_agent, groq_chatbot, get_tools, summarizer_model from PIL import Image from io import BytesIO import base64 import docx from streamlit_lottie import st_lottie import json from utils import set_safety_settings, about from streamlit_mic_recorder import speech_to_text import google.generativeai as genai import os, random, validators import time import tempfile import asyncio import edge_tts st.set_page_config( page_title="Super AI Assistant", page_icon="⚑", layout="wide", initial_sidebar_state="auto", menu_items={"About": about(), "Get Help":"https://www.linkedin.com/in/aasher-kamal-a227a124b/"}, ) ###--- Title ---### st.markdown("""

Super AI Assistant

""", unsafe_allow_html=True) google_models = [ "gemini-1.5-flash", "gemini-1.5-pro", ] groq_models = [ "llama-3.1-8b-instant", "llama-3.1-70b-versatile", "llama3-70b-8192", "llama3-8b-8192", "gemma2-9b-it", "mixtral-8x7b-32768" ] voices = { "William":"en-AU-WilliamNeural", "James":"en-PH-JamesNeural", "Jenny":"en-US-JennyNeural", "US Guy":"en-US-GuyNeural", "Sawara":"hi-IN-SwaraNeural", } @st.cache_data def load_lottie_file(filepath: str): with open(filepath, "r") as f: return json.load(f) ###--- FUNCTION FOR SPEECH GENERATION---### async def generate_speech(text, voice): communicate = edge_tts.Communicate(text, voice) with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as temp_file: await communicate.save(temp_file.name) temp_file_path = temp_file.name return temp_file_path ###---AUTOPLAY SPEECH---### def get_audio_player(file_path): with open(file_path, "rb") as f: data = f.read() b64 = base64.b64encode(data).decode() return f'