muzammil-eds commited on
Commit
2910afc
1 Parent(s): be99e76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -32
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import requests
3
  import Levenshtein
 
4
  from io import BytesIO
5
  import librosa
6
  import torch
@@ -64,44 +65,15 @@ st.title("Audio Transcription and Similarity Checker")
64
 
65
  # Choose between upload or record
66
  st.sidebar.header("Input Method")
67
- input_method = st.sidebar.selectbox("Choose Input Method", ["Upload", "Record"])
68
 
69
  original_audio_bytes = None
70
  user_audio_bytes = None
71
 
72
- if input_method == "Upload":
73
- # Upload original audio file
74
- original_audio = st.file_uploader("Upload Original Audio", type=["wav", "mp3"])
75
- # Upload user audio file
76
- user_audio = st.file_uploader("Upload User Audio", type=["wav", "mp3"])
77
 
78
- if original_audio:
79
- original_audio_bytes = original_audio.read()
80
- st.audio(original_audio_bytes, format="audio/wav")
81
- if user_audio:
82
- user_audio_bytes = user_audio.read()
83
- st.audio(user_audio_bytes, format="audio/wav")
84
-
85
- # Add a button to perform the test
86
- if original_audio_bytes and user_audio_bytes:
87
- if st.button("Perform Testing"):
88
- with st.spinner("Performing transcription and similarity testing..."):
89
- transcription_original, transcription_user, similarity_score = evaluate_audio_similarity(original_audio_bytes, user_audio_bytes)
90
-
91
- # Display results
92
- st.markdown("---")
93
- st.subheader("Transcriptions and Similarity Score")
94
- st.write(f"**Original Transcription:** {transcription_original}")
95
- st.write(f"**User Transcription:** {transcription_user}")
96
- st.write(f"**Levenshtein Similarity Score:** {similarity_score:.2f}")
97
-
98
- if similarity_score > 0.8: # Adjust the threshold as needed
99
- st.success("The pronunciation is likely correct based on transcription similarity.")
100
- else:
101
- st.error("The pronunciation may be incorrect based on transcription similarity.")
102
-
103
- elif input_method == "Record":
104
  st.write("Record or Upload Original Audio")
 
105
  original_audio_bytes = audio_recorder(key="original_audio_recorder", pause_threshold=30, icon_size='4x')
106
 
107
  if not original_audio_bytes:
 
1
  import streamlit as st
2
  import requests
3
  import Levenshtein
4
+ import time
5
  from io import BytesIO
6
  import librosa
7
  import torch
 
65
 
66
  # Choose between upload or record
67
  st.sidebar.header("Input Method")
68
+ input_method = st.sidebar.selectbox("Choose Input Method", ["Record"])
69
 
70
  original_audio_bytes = None
71
  user_audio_bytes = None
72
 
 
 
 
 
 
73
 
74
+ if input_method == "Record":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  st.write("Record or Upload Original Audio")
76
+ time.sleep(2)
77
  original_audio_bytes = audio_recorder(key="original_audio_recorder", pause_threshold=30, icon_size='4x')
78
 
79
  if not original_audio_bytes: