Spaces:
Sleeping
Sleeping
Update app.py
Browse files13 unmodified lines141516171718192012 unmodified lines3334353637363738394041424344454643474849505120 unmodified lines7273747013 unmodified lines os.system(f"start {temp_file.name}") # Windows return "✅ Text is being read out. Please listen and read it yourself."
# Function to transcribe user's audio# Function to transcribe user's audio and compare with the original textdef transcribe_audio(audio, original_text): recognizer = sr.Recognizer() with sr.AudioFile(audio) as source:12 unmodified lines # Calculate speed duration = end_time - start_time # time to process (not speaking time) # Better: estimate speaking time from audio length if needed (advanced) speed = round(len(transcribed_words) / duration, 2) # words per second # Compare words and highlight mistakes wrong_words = [] for i, word in enumerate(original_words): if i >= len(transcribed_words) or word != transcribed_words[i]: wrong_words.append(f"🔴 {word}") result = { "📝 Transcribed Text": transcription, "🎯 Accuracy (%)": accuracy, "⏱️ Speaking Speed (words/sec)": speed "⏱️ Speaking Speed (words/sec)": speed, "❌ Incorrect Words": ' '.join(wrong_words) if wrong_words else "None" } return result except Exception as e:20 unmodified lines
# Launch the appapp.launch()
app.py+9-5