Spaces:
Sleeping
Sleeping
muzammil-eds
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -40,27 +40,41 @@ def evaluate_audio_similarity(original_audio_bytes, user_audio_bytes):
|
|
40 |
|
41 |
st.title("Audio Transcription and Similarity Checker")
|
42 |
|
43 |
-
#
|
44 |
-
st.
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
st.
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
st.session_state['initialized'] = True
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if not original_audio_bytes:
|
66 |
original_audio = st.file_uploader("Or Upload Original Audio", type=["wav", "mp3"])
|
@@ -71,8 +85,19 @@ if input_method == "Record":
|
|
71 |
with st.spinner("Processing original audio..."):
|
72 |
st.audio(original_audio_bytes, format="audio/wav")
|
73 |
|
74 |
-
st.
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
if not user_audio_bytes:
|
78 |
user_audio = st.file_uploader("Or Upload User Audio", type=["wav", "mp3"])
|
@@ -96,7 +121,7 @@ if input_method == "Record":
|
|
96 |
st.write(f"**User Transcription:** {transcription_user}")
|
97 |
st.write(f"**Levenshtein Similarity Score:** {similarity_score:.2f}")
|
98 |
|
99 |
-
if similarity_score > 0.8:
|
100 |
st.success("The pronunciation is likely correct based on transcription similarity.")
|
101 |
else:
|
102 |
st.error("The pronunciation may be incorrect based on transcription similarity.")
|
|
|
40 |
|
41 |
st.title("Audio Transcription and Similarity Checker")
|
42 |
|
43 |
+
# Initialize the session state to control the view
|
44 |
+
if 'initialized' not in st.session_state:
|
45 |
+
st.session_state['initialized'] = False
|
46 |
+
|
47 |
+
# Button to initialize the recorders
|
48 |
+
if not st.session_state['initialized']:
|
49 |
+
|
50 |
+
st.write("Click the Loader below to initialize the audio recorders.")
|
51 |
+
|
52 |
+
if st.button('Click to start recording'):
|
53 |
+
init_button = audio_recorder(
|
54 |
+
text="",
|
55 |
+
recording_color="#e8b62c",
|
56 |
+
neutral_color="#6aa36f",
|
57 |
+
pause_threshold=0.1,
|
58 |
+
icon_name="", # You can change this to any Font Awesome solid icon
|
59 |
+
icon_size="4x",
|
60 |
+
auto_start=True
|
61 |
+
)
|
62 |
st.session_state['initialized'] = True
|
63 |
+
|
64 |
+
# If initialized, display the recorders
|
65 |
+
if st.session_state['initialized']:
|
66 |
+
|
67 |
+
st.subheader("Record or Upload Original Audio")
|
68 |
+
|
69 |
+
# Style the record button with the provided parameters
|
70 |
+
original_audio_bytes = audio_recorder(
|
71 |
+
text="Click to Record Audio",
|
72 |
+
recording_color="#e8b62c",
|
73 |
+
neutral_color="#6aa36f",
|
74 |
+
pause_threshold=30,
|
75 |
+
icon_name="microphone", # You can change this to any Font Awesome solid icon
|
76 |
+
icon_size="4x"
|
77 |
+
)
|
78 |
|
79 |
if not original_audio_bytes:
|
80 |
original_audio = st.file_uploader("Or Upload Original Audio", type=["wav", "mp3"])
|
|
|
85 |
with st.spinner("Processing original audio..."):
|
86 |
st.audio(original_audio_bytes, format="audio/wav")
|
87 |
|
88 |
+
st.subheader("Record or Upload User Audio")
|
89 |
+
|
90 |
+
st.write("")
|
91 |
+
|
92 |
+
# Style the user audio recorder similarly
|
93 |
+
user_audio_bytes = audio_recorder(
|
94 |
+
text="Click to Record Audio",
|
95 |
+
recording_color="#e86f6f",
|
96 |
+
neutral_color="#6a6faf",
|
97 |
+
pause_threshold=30,
|
98 |
+
icon_name="user", # You can change this to any Font Awesome solid icon
|
99 |
+
icon_size="4x"
|
100 |
+
)
|
101 |
|
102 |
if not user_audio_bytes:
|
103 |
user_audio = st.file_uploader("Or Upload User Audio", type=["wav", "mp3"])
|
|
|
121 |
st.write(f"**User Transcription:** {transcription_user}")
|
122 |
st.write(f"**Levenshtein Similarity Score:** {similarity_score:.2f}")
|
123 |
|
124 |
+
if similarity_score > 0.8: # Adjust the threshold as needed
|
125 |
st.success("The pronunciation is likely correct based on transcription similarity.")
|
126 |
else:
|
127 |
st.error("The pronunciation may be incorrect based on transcription similarity.")
|