cdleong commited on
Commit
f9db145
·
1 Parent(s): c198ba3

restrict to .wav format, working on mp3 support next

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -3,7 +3,10 @@ import langcodes
3
  from allosaurus.app import read_recognizer
4
 
5
 
6
-
 
 
 
7
 
8
 
9
  def get_langcode_for_allosaurus(input_code):
@@ -28,9 +31,16 @@ if __name__ == "__main__":
28
 
29
  model = read_recognizer()
30
 
31
- uploaded_file = st.file_uploader("Choose a file")
 
 
 
 
 
32
  if uploaded_file is not None:
33
- audio_bytes = uploaded_file.getvalue()
 
 
34
  # audio_bytes = audio_file.read()
35
  st.audio(audio_bytes, format='audio/wav')
36
 
 
3
  from allosaurus.app import read_recognizer
4
 
5
 
6
+ def get_bytes_in_wav_format(uploaded_file):
7
+ if ".wav" in uploaded_file:
8
+ return uploaded_file.getvalue()
9
+ # TODO: .mp3 conversion
10
 
11
 
12
  def get_langcode_for_allosaurus(input_code):
 
31
 
32
  model = read_recognizer()
33
 
34
+ uploaded_file = st.file_uploader("Choose a file", type=[
35
+ ".wav",
36
+ # ".mp3",
37
+ ])
38
+
39
+
40
  if uploaded_file is not None:
41
+ audio_bytes = get_bytes_in_wav_format()
42
+
43
+
44
  # audio_bytes = audio_file.read()
45
  st.audio(audio_bytes, format='audio/wav')
46