Zasha1 commited on
Commit
248ac9a
·
verified ·
1 Parent(s): 342f0a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -38,21 +38,24 @@ def numpy_to_audio_data(audio_data):
38
 
39
  def real_time_analysis():
40
  recognizer = sr.Recognizer()
 
 
 
 
41
  sentiment_scores = []
42
  transcribed_chunks = []
43
  total_text = ""
44
 
45
  try:
46
  while True:
47
- # Record audio using sounddevice
48
- audio_array, sample_rate = record_audio()
49
-
50
- # Convert NumPy array to AudioData
51
- audio_data = numpy_to_audio_data(audio_array)
52
 
53
  try:
54
- # Transcribe using speech_recognition
55
- text = recognizer.recognize_google(audio_data)
56
  st.write(f"*Recognized Text:* {text}")
57
 
58
  if 'stop' in text.lower():
@@ -114,6 +117,7 @@ def real_time_analysis():
114
  except Exception as e:
115
  st.error(f"Error in real-time analysis: {e}")
116
 
 
117
  def generate_comprehensive_summary(chunks):
118
  """
119
  Generate a comprehensive summary from conversation chunks
 
38
 
39
  def real_time_analysis():
40
  recognizer = sr.Recognizer()
41
+ mic = sr.Microphone()
42
+
43
+ st.info("Say 'stop' to end the process.")
44
+
45
  sentiment_scores = []
46
  transcribed_chunks = []
47
  total_text = ""
48
 
49
  try:
50
  while True:
51
+ with mic as source:
52
+ st.write("Listening...")
53
+ recognizer.adjust_for_ambient_noise(source)
54
+ audio = recognizer.listen(source)
 
55
 
56
  try:
57
+ st.write("Recognizing...")
58
+ text = recognizer.recognize_google(audio)
59
  st.write(f"*Recognized Text:* {text}")
60
 
61
  if 'stop' in text.lower():
 
117
  except Exception as e:
118
  st.error(f"Error in real-time analysis: {e}")
119
 
120
+
121
  def generate_comprehensive_summary(chunks):
122
  """
123
  Generate a comprehensive summary from conversation chunks