Afeezee commited on
Commit
aa276b4
·
verified ·
1 Parent(s): ad555cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -10
app.py CHANGED
@@ -8,13 +8,6 @@ import soundfile as sf
8
  # Initialize Groq client with API key
9
  client = Groq(api_key="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")
10
 
11
- # Convert sound data to bytes
12
- def sound_to_bytes(sound_data):
13
- buffer = io.BytesIO()
14
- sf.write(buffer, sound_data, 44100, format='WAV')
15
- buffer.seek(0)
16
- return buffer.read()
17
-
18
  # Initialize score tracking
19
  score = 0
20
  attempts = 0
@@ -73,13 +66,11 @@ def check_pronunciation(audio, word):
73
  similarity = SequenceMatcher(None, transcription_text.lower(), word.lower()).ratio()
74
  if similarity > 0.8: # Threshold for correct pronunciation
75
  score += 1
76
- feedback_audio = sound_to_bytes(correct_sound)
77
  result_text = f"Correct! Expected: {word}. You said: {transcription_text}"
78
  else:
79
- feedback_audio = sound_to_bytes(incorrect_sound)
80
  result_text = f"Incorrect. Expected: {word}. You said: {transcription_text}"
81
 
82
- return result_text, score, feedback_audio
83
  except Exception as e:
84
  return f"Error checking pronunciation: {e}", score, None
85
 
 
8
  # Initialize Groq client with API key
9
  client = Groq(api_key="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")
10
 
 
 
 
 
 
 
 
11
  # Initialize score tracking
12
  score = 0
13
  attempts = 0
 
66
  similarity = SequenceMatcher(None, transcription_text.lower(), word.lower()).ratio()
67
  if similarity > 0.8: # Threshold for correct pronunciation
68
  score += 1
 
69
  result_text = f"Correct! Expected: {word}. You said: {transcription_text}"
70
  else:
 
71
  result_text = f"Incorrect. Expected: {word}. You said: {transcription_text}"
72
 
73
+ return result_text, score
74
  except Exception as e:
75
  return f"Error checking pronunciation: {e}", score, None
76