Martijn Bartelds commited on
Commit
da8f6fb
1 Parent(s): 6d08c06

Update app files

Browse files
Files changed (1) hide show
  1. neural_acoustic_distance.py +12 -2
neural_acoustic_distance.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
@@ -102,6 +103,11 @@ def compute_costs(gcm):
102
  res = [np.mean(x) for x in res]
103
  return res, n
104
 
 
 
 
 
 
105
  st.subheader("Audio file selection:")
106
 
107
  filename_x = st.selectbox(
@@ -110,8 +116,10 @@ filename_x = st.selectbox(
110
 
111
  if filename_x == "falling_huud_mobiel_201145.wav":
112
  filename_x = "./examples/falling_huud_mobiel_201145.wav"
 
113
  if filename_x == "falling_hood_mobiel_203936.wav":
114
  filename_x = "./examples/falling_hood_mobiel_203936.wav"
 
115
 
116
  filename_y = st.selectbox(
117
  "Filename (y-axis):",
@@ -119,13 +127,15 @@ filename_y = st.selectbox(
119
 
120
  if filename_y == "falling_huud_mobiel_201145.wav":
121
  filename_y = "./examples/falling_huud_mobiel_201145.wav"
 
122
  if filename_y == "falling_hood_mobiel_203936.wav":
123
  filename_y = "./examples/falling_hood_mobiel_203936.wav"
 
124
 
125
  if filename_x == "custom upload":
126
- filename_x = st.file_uploader("Choose a file", key = "f_x")
127
  if filename_y == "custom upload":
128
- filename_y = st.file_uploader("Choose a file", key = "f_y")
129
 
130
  if filename_x is not None and filename_y is not None and featurizer_a is not None:
131
  print(f"\nX: {filename_x}\nY: {filename_y}")
 
1
+ from unicodedata import name
2
  import streamlit as st
3
  import pandas as pd
4
  import numpy as np
 
103
  res = [np.mean(x) for x in res]
104
  return res, n
105
 
106
+ def play_audio(filename):
107
+ audio_file = open(filename, "rb")
108
+ audio_bytes = audio_file.read()
109
+ st.audio(audio_bytes, format="audio/wav")
110
+
111
  st.subheader("Audio file selection:")
112
 
113
  filename_x = st.selectbox(
 
116
 
117
  if filename_x == "falling_huud_mobiel_201145.wav":
118
  filename_x = "./examples/falling_huud_mobiel_201145.wav"
119
+ play_audio(filename_x)
120
  if filename_x == "falling_hood_mobiel_203936.wav":
121
  filename_x = "./examples/falling_hood_mobiel_203936.wav"
122
+ play_audio(filename_x)
123
 
124
  filename_y = st.selectbox(
125
  "Filename (y-axis):",
 
127
 
128
  if filename_y == "falling_huud_mobiel_201145.wav":
129
  filename_y = "./examples/falling_huud_mobiel_201145.wav"
130
+ play_audio(filename_y)
131
  if filename_y == "falling_hood_mobiel_203936.wav":
132
  filename_y = "./examples/falling_hood_mobiel_203936.wav"
133
+ play_audio(filename_y)
134
 
135
  if filename_x == "custom upload":
136
+ filename_x = st.file_uploader("Choose a file (x-axis)", key = "f_x")
137
  if filename_y == "custom upload":
138
+ filename_y = st.file_uploader("Choose a file (y-axis)", key = "f_y")
139
 
140
  if filename_x is not None and filename_y is not None and featurizer_a is not None:
141
  print(f"\nX: {filename_x}\nY: {filename_y}")