Introduction
SANGAM AI is an all-in-one AI toolkit built with Python and Streamlit. It brings together four powerful capabilities ā text generation, speech synthesis, image creation, and video processing ā in a single, easy-to-use web app. SANGAM combines several models into one app. For a deeper dive into the chat side, see the Mistral AI chatbot tutorial.
> š¬ Watch the Full Video Tutorial:
> Learn how to build it step-by-step on YouTube: The 7th Semester Project That Will Make You a SANGAM AI Master
What SANGAM AI Can Do
Prerequisites
Install the required libraries:
pip install streamlit mistralai gtts Pillow requestsYou will also need a Mistral AI API key from mistral.ai.
Project Structure
sangam_ai/
āāā app.py
āāā modules/
ā āāā text_gen.py
ā āāā tts.py
ā āāā image_gen.py
ā āāā video.py
āāā requirements.txtStep 1: Set Up the Main App
Create app.py with a sidebar for navigation:
import streamlit as st
st.set_page_config(page_title="SANGAM AI", page_icon="š¤", layout="wide")
st.title("š¤ SANGAM AI ā Your All-in-One AI Toolkit")
mode = st.sidebar.selectbox(
"Choose a Tool",
["Text Generation", "Text to Speech", "Image Generation", "Video Processing"]
)
if mode == "Text Generation":
from modules.text_gen import run
run()
elif mode == "Text to Speech":
from modules.tts import run
run()
elif mode == "Image Generation":
from modules.image_gen import run
run()
else:
from modules.video import run
run()Step 2: Text Generation Module
Create modules/text_gen.py:
import streamlit as st
from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage
def run():
st.header("š Text Generation")
api_key = st.text_input("Mistral API Key", type="password")
prompt = st.text_area("Enter your prompt:")
if st.button("Generate") and api_key and prompt:
client = MistralClient(api_key=api_key)
response = client.chat(
model="mistral-small",
messages=[ChatMessage(role="user", content=prompt)]
)
st.write(response.choices[0].message.content)Step 3: Text-to-Speech Module
Create modules/tts.py:
import streamlit as st
from gtts import gTTS
import io
def run():
st.header("š Text to Speech")
text = st.text_area("Enter text to convert:")
lang = st.selectbox("Language", ["en", "hi", "es", "fr", "de"])
if st.button("Convert") and text:
tts = gTTS(text=text, lang=lang)
audio_bytes = io.BytesIO()
tts.write_to_fp(audio_bytes)
audio_bytes.seek(0)
st.audio(audio_bytes, format="audio/mp3")
st.download_button("Download Audio", audio_bytes, file_name="speech.mp3")Step 4: Run SANGAM AI
streamlit run app.pyHow It Works
SANGAM AI is essentially a multi-page Streamlit app driven by st.sidebar.radio() as a router: each option renders a different module, which keeps every capability isolated in its own file. This matters as apps grow ā one file per feature is far easier to debug than a single 500-line script.
The text module calls the Mistral API with requests and reads response.json()["choices"][0]["message"]["content"]. Because API calls take seconds, the app shows st.spinner() while waiting ā a small touch that massively improves perceived speed.
The voice module passes generated text to gTTS, which returns an MP3 that Streamlit can play natively with st.audio(). The image module wraps Pillow to apply filters and resize operations on uploads. If you want to go deeper on any one capability, the dedicated text-to-speech tutorial and sentiment analysis guide cover the modules in isolation.
Key Concepts
What to Try Next
st.session_state.Common Errors & Fixes
os.environ.get("MISTRAL_API_KEY") and confirm it is exported in the shell *before* launching Streamlit."en") and print the response length to debug.img.convert("RGB").key= arguments per module.FAQ
Do I need a paid Mistral account?
No ā Mistral offers a free tier that is plenty for learning. You do need to register an API key and keep it in an environment variable.
Can I deploy SANGAM AI to the cloud?
Yes, Streamlit Community Cloud works. Add your API key in the app's Secrets settings rather than committing it to GitHub.
Why split modules into separate files?
Isolation: a crash in the image module no longer takes down chat, and you can reuse modules in other projects ā the TTS module is a drop-in fit for the gTTS app.