|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
audio_classifier = pipeline( |
|
"audio-classification", model="HareemFatima/distilhubert-finetuned-stutterdetection" |
|
) |
|
|
|
|
|
|
|
def tts(text): |
|
|
|
|
|
return f"Synthesized speech for therapy: {text}" |
|
|
|
|
|
therapy_text = { |
|
"Normal Speech": "Your speech sounds great! Keep practicing!", |
|
"Blocking": "Take a deep breath and try speaking slowly. You can do it!", |
|
"Prolongation": "Focus on relaxing your mouth muscles and speaking smoothly.", |
|
|
|
} |
|
|
|
st.title("Stuttering Therapy Assistant") |
|
st.write("This app helps you identify stuttering types and provides personalized therapy suggestions.") |
|
|
|
uploaded_audio = st.file_uploader("Upload Audio Clip") |
|
|
|
if uploaded_audio is not None: |
|
|
|
audio_bytes = uploaded_audio.read() |
|
|
|
|
|
prediction = audio_classifier(audio_bytes) |
|
stutter_type = prediction[0]["label"] |
|
|
|
|
|
therapy = therapy_text.get(stutter_type, "General therapy tip: Practice slow, relaxed speech.") |
|
|
|
|
|
synthesized_speech = tts(therapy) |
|
|
|
st.write(f"Predicted Stutter Type: {stutter_type}") |
|
st.write(f"Therapy Tip: {therapy}") |
|
st.audio(synthesized_speech) |
|
|
|
|