ibrahim313 commited on
Commit
c570be6
·
verified ·
1 Parent(s): 92a6ccc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -16
app.py CHANGED
@@ -2,6 +2,9 @@ import os
2
  import streamlit as st
3
  import pandas as pd
4
  from groq import Groq
 
 
 
5
 
6
  # Set your API key (replace with secure method for production)
7
  API_KEY = "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"
@@ -24,7 +27,7 @@ if st.sidebar.button("Register"):
24
 
25
  # Diagnostic Test
26
  st.header("Diagnostic Test")
27
- assessment_text = st.text_area("Read the following text aloud:", "Sample text for assessment...")
28
  if st.button("Submit Assessment"):
29
  if assessment_text:
30
  # Call the LLAMA model for feedback based on assessment
@@ -45,32 +48,41 @@ if st.button("Submit Assessment"):
45
  # Personalized Reading Material
46
  st.header("Generate Personalized Reading Material")
47
  if st.button("Generate Reading Material"):
48
- generated_text = "Generated personalized text focusing on phonetic patterns." # Placeholder for personalized content
49
  st.text_area("Your Personalized Reading Material:", generated_text, height=200)
50
 
51
- # User Feedback
52
- st.header("Feedback Collection")
53
- feedback = st.text_area("Your Feedback:")
54
- if st.button("Submit Feedback"):
55
- if feedback:
56
- # Placeholder for storing feedback (e.g., to Google Sheets)
57
- st.success("Feedback submitted successfully!")
58
- else:
59
- st.error("Please provide your feedback.")
60
 
61
- # Audio Transcription
62
- st.header("Audio Transcription")
63
- filename = st.file_uploader("Upload your audio file (m4a):", type=["m4a"])
64
- if filename is not None:
65
  if st.button("Transcribe Audio"):
 
66
  with open(filename, "rb") as file:
67
  transcription = client.audio.transcriptions.create(
68
- file=(filename.name, file.read()),
69
  model="whisper-large-v3",
70
  response_format="verbose_json",
71
  )
72
  st.write("Transcription:", transcription.text)
73
 
 
 
 
 
 
 
 
 
 
 
74
  # Visualization (User Progress)
75
  st.header("User Progress Visualization")
76
  # Placeholder for progress data visualization
 
2
  import streamlit as st
3
  import pandas as pd
4
  from groq import Groq
5
+ import sounddevice as sd
6
+ import numpy as np
7
+ import wavio
8
 
9
  # Set your API key (replace with secure method for production)
10
  API_KEY = "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"
 
27
 
28
  # Diagnostic Test
29
  st.header("Diagnostic Test")
30
+ assessment_text = st.text_area("Read the following text aloud:", "Sample text for assessment: The quick brown fox jumps over the lazy dog.")
31
  if st.button("Submit Assessment"):
32
  if assessment_text:
33
  # Call the LLAMA model for feedback based on assessment
 
48
  # Personalized Reading Material
49
  st.header("Generate Personalized Reading Material")
50
  if st.button("Generate Reading Material"):
51
+ generated_text = "Generated personalized text focusing on phonetic patterns: 'sh', 'ch', and 'th'." # Placeholder for personalized content
52
  st.text_area("Your Personalized Reading Material:", generated_text, height=200)
53
 
54
+ # Audio Recording Feature
55
+ st.header("Record Your Voice")
56
+ duration = st.number_input("Duration of recording (seconds)", min_value=1, max_value=60, value=5)
57
+ if st.button("Record Audio"):
58
+ st.write("Recording...")
59
+ recording = sd.rec(int(duration * 44100), samplerate=44100, channels=2)
60
+ sd.wait() # Wait until the recording is finished
61
+ wavio.write("recording.wav", recording, 44100, sampwidth=2) # Save as WAV file
62
+ st.success("Recording completed!")
63
 
64
+ # Upload Recorded Audio for Transcription
65
+ if st.file_uploader("Upload your audio file (m4a):", type=["m4a"]) is not None:
 
 
66
  if st.button("Transcribe Audio"):
67
+ filename = "recording.wav" # Use the recorded file for transcription
68
  with open(filename, "rb") as file:
69
  transcription = client.audio.transcriptions.create(
70
+ file=(filename, file.read()),
71
  model="whisper-large-v3",
72
  response_format="verbose_json",
73
  )
74
  st.write("Transcription:", transcription.text)
75
 
76
+ # Feedback Collection
77
+ st.header("Feedback Collection")
78
+ feedback = st.text_area("Your Feedback:")
79
+ if st.button("Submit Feedback"):
80
+ if feedback:
81
+ # Placeholder for storing feedback (e.g., to Google Sheets)
82
+ st.success("Feedback submitted successfully!")
83
+ else:
84
+ st.error("Please provide your feedback.")
85
+
86
  # Visualization (User Progress)
87
  st.header("User Progress Visualization")
88
  # Placeholder for progress data visualization