Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,7 @@ except Exception as e:
|
|
24 |
# model_path = 'TrillsonFeature_model'
|
25 |
# m = hub.load(model_path)
|
26 |
m = hub.KerasLayer('https://tfhub.dev/google/nonsemantic-speech-benchmark/trillsson4/1')
|
|
|
27 |
class TransformerEncoder(tf.keras.layers.Layer):
|
28 |
def __init__(self, embed_dim, num_heads, ff_dim, rate=0.01, **kwargs):
|
29 |
super(TransformerEncoder, self).__init__(**kwargs)
|
@@ -163,10 +164,11 @@ if option == "Upload an audio file":
|
|
163 |
start_time = time.time() # Record start time
|
164 |
with st.spinner('Extracting features...'):
|
165 |
# Process the uploaded file
|
166 |
-
|
|
|
167 |
f.write(uploaded_file.getbuffer())
|
168 |
-
features = extract_features(
|
169 |
-
os.remove(
|
170 |
run_prediction(features)
|
171 |
elapsed_time = round(time.time() - start_time, 2)
|
172 |
st.write(f"Elapsed Time: {elapsed_time} seconds")
|
@@ -271,7 +273,7 @@ else: # Option is "Record audio"
|
|
271 |
const audioUrl = URL.createObjectURL(audioBlob);
|
272 |
const a = document.createElement('a');
|
273 |
a.href = audioUrl;
|
274 |
-
a.download = '
|
275 |
document.body.appendChild(a);
|
276 |
a.click();
|
277 |
|
|
|
24 |
# model_path = 'TrillsonFeature_model'
|
25 |
# m = hub.load(model_path)
|
26 |
m = hub.KerasLayer('https://tfhub.dev/google/nonsemantic-speech-benchmark/trillsson4/1')
|
27 |
+
|
28 |
class TransformerEncoder(tf.keras.layers.Layer):
|
29 |
def __init__(self, embed_dim, num_heads, ff_dim, rate=0.01, **kwargs):
|
30 |
super(TransformerEncoder, self).__init__(**kwargs)
|
|
|
164 |
start_time = time.time() # Record start time
|
165 |
with st.spinner('Extracting features...'):
|
166 |
# Process the uploaded file
|
167 |
+
temp_audio_path = os.path.join(".", "temp_audio.wav")
|
168 |
+
with open(temp_audio_path, "wb") as f:
|
169 |
f.write(uploaded_file.getbuffer())
|
170 |
+
features = extract_features(temp_audio_path)
|
171 |
+
os.remove(temp_audio_path)
|
172 |
run_prediction(features)
|
173 |
elapsed_time = round(time.time() - start_time, 2)
|
174 |
st.write(f"Elapsed Time: {elapsed_time} seconds")
|
|
|
273 |
const audioUrl = URL.createObjectURL(audioBlob);
|
274 |
const a = document.createElement('a');
|
275 |
a.href = audioUrl;
|
276 |
+
a.download = 'recorded_audio.wav';
|
277 |
document.body.appendChild(a);
|
278 |
a.click();
|
279 |
|