Spaces:
Sleeping
Sleeping
Update app.py
Browse files13 unmodified lines1415161718192012 unmodified lines333435363738394041424344454620 unmodified lines6768697013 unmodified linesos.system(f"start {temp_file.name}") # Windowsreturn "✅ Text is being read out. Please listen and read it yourself."# Function to transcribe user's audiodef transcribe_audio(audio, original_text):recognizer = sr.Recognizer()with sr.AudioFile(audio) as source:12 unmodified lines# Calculate speedduration = 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 secondresult = {"📝 Transcribed Text": transcription,"🎯 Accuracy (%)": accuracy,"⏱️ Speaking Speed (words/sec)": speed}return resultexcept Exception as e:20 unmodified lines# Launch the appapp.launch()13 unmodified lines1415161718192012 unmodified lines3334353637383940414243444546474849505120 unmodified lines72737413 unmodified linesos.system(f"start {temp_file.name}") # Windowsreturn "✅ Text is being read out. Please listen and read it yourself."# 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 speedduration = end_time - start_time # time to process (not speaking time)speed = round(len(transcribed_words) / duration, 2) # words per second# Compare words and highlight mistakeswrong_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,"❌ Incorrect Words": ' '.join(wrong_words) if wrong_words else "None"}return resultexcept Exception as e:20 unmodified lines# Launch the appapp.launch()
app.py+9-5