Skip to content

Add Streamlit UI for real-time SER predictions; update README and requirements#1

Open
Saurabh620 wants to merge 1 commit into
mainfrom
codex/read-repository-documentation
Open

Add Streamlit UI for real-time SER predictions; update README and requirements#1
Saurabh620 wants to merge 1 commit into
mainfrom
codex/read-repository-documentation

Conversation

@Saurabh620
Copy link
Copy Markdown
Owner

Motivation

  • Provide an interactive Streamlit interface to run inference with the trained Speech Emotion Recognition (SER) model for quick predictions.
  • Improve repository documentation and usage instructions to include running the Streamlit app and model path expectations.
  • Ensure the project dependencies include Streamlit so the UI can be executed reproducibly.

Description

  • Add a new streamlit_app.py that loads a Keras/TensorFlow model, extracts MFCC features from uploaded audio, runs inference, and displays predicted emotion, class probabilities, and a bar chart.
  • Implement extract_mfcc_from_bytes to read audio bytes with soundfile, resample to 22050 Hz, slice/pad a 3s window, compute 40 MFCCs, and shape the result as (1, 40, 1).
  • Use st.cache_resource to cache the loaded model via get_model, and include robust model-loading fallback between keras and tensorflow.keras.
  • Update README.md with step-by-step run instructions and a new "Streamlit UI (optimized)" section, and add streamlit==1.45.1 to requirements.txt.

Testing

  • No automated tests were run for these changes.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 329129b476

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread streamlit_app.py
Comment on lines +78 to +79
features = extract_mfcc_from_bytes(audio_bytes)
probs = model.predict(features, verbose=0)[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize MFCC features with training scaler

main() feeds raw MFCC vectors directly into model.predict, but the training notebook standardizes inputs (MainProgram.ipynb builds X_normalized with StandardScaler and trains on that tensor). Skipping the same scaler at inference creates a train/serve feature mismatch that can materially distort class probabilities and predicted emotions for normal user uploads; the app should load and apply the exact scaler used during training before prediction.

Useful? React with 👍 / 👎.

Comment thread streamlit_app.py
if not model_exists:
st.warning(f"Model file not found: `{model_path}`. Upload audio is disabled until model is available.")

uploaded = st.file_uploader("Upload audio", type=["wav", "mp3", "ogg", "flac", "m4a"])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove unsupported uploaded audio extensions

The uploader advertises mp3 and m4a, but decoding is done solely through soundfile.read in extract_mfcc_from_bytes with no fallback or error handling. In environments using the pinned soundfile==0.10.3.post1, these compressed formats are often not decodable (especially m4a), so selecting such a file can raise a runtime decode error instead of producing a prediction; either restrict allowed types to guaranteed codecs or add a robust fallback decoder path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant