Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -5
src/streamlit_app.py
CHANGED
@@ -62,9 +62,9 @@ def split_audio(file):
|
|
62 |
print(f"Error processing file: {e}")
|
63 |
return None
|
64 |
|
65 |
-
def accent_classify(pipe, audio_path):
|
66 |
-
|
67 |
-
|
68 |
|
69 |
accent_mapping = {
|
70 |
'us': 'American',
|
@@ -94,11 +94,15 @@ if st.button("Analyze"):
|
|
94 |
# result = whisper_model.transcribe(audio_path)
|
95 |
# transcription = result['text']
|
96 |
# # pass
|
97 |
-
|
|
|
|
|
|
|
98 |
with st.spinner("Classifying accent..."):
|
99 |
model_name = "dima806/english_accents_classification"
|
100 |
pipe = pipeline('audio-classification', model=model_name, device=0)
|
101 |
-
accent_data = accent_classify(pipe, audio_path)
|
|
|
102 |
accent = accent_mapping.get(accent_data.get("label", "us"))
|
103 |
confidence = accent_data.get("score", 0)
|
104 |
|
|
|
62 |
print(f"Error processing file: {e}")
|
63 |
return None
|
64 |
|
65 |
+
# def accent_classify(pipe, audio_path):
|
66 |
+
# audio_df = split_audio(audio_path)
|
67 |
+
# return pipe(np.concatenate(audio_df["audio"][:250].to_list()))[0]
|
68 |
|
69 |
accent_mapping = {
|
70 |
'us': 'American',
|
|
|
94 |
# result = whisper_model.transcribe(audio_path)
|
95 |
# transcription = result['text']
|
96 |
# # pass
|
97 |
+
with st.spinner("Extracting waves..."):
|
98 |
+
audio_df = split_audio(audio_path)
|
99 |
+
waves = np.concatenate(audio_df["audio"][:250].to_list())
|
100 |
+
|
101 |
with st.spinner("Classifying accent..."):
|
102 |
model_name = "dima806/english_accents_classification"
|
103 |
pipe = pipeline('audio-classification', model=model_name, device=0)
|
104 |
+
# accent_data = accent_classify(pipe, audio_path)
|
105 |
+
accent_data = pipe(waves)[0]
|
106 |
accent = accent_mapping.get(accent_data.get("label", "us"))
|
107 |
confidence = accent_data.get("score", 0)
|
108 |
|