zhuohan-7 commited on
Commit
5e2340a
·
1 Parent(s): d897828

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app/show_examples.py +14 -5
app/show_examples.py CHANGED
@@ -1,6 +1,8 @@
1
  import streamlit as st
2
  import datasets
3
  import numpy as np
 
 
4
 
5
  import html
6
 
@@ -19,9 +21,15 @@ def show_dataset_examples(display_name):
19
  st.markdown(f'##### Example-{index+1}')
20
  col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center")
21
 
22
- # with col1:
23
- st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav")
24
-
 
 
 
 
 
 
25
  if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
26
 
27
  choices = dataset[index]['other_attributes']['choices']
@@ -36,7 +44,8 @@ def show_dataset_examples(display_name):
36
 
37
  question_text = html.escape(question_text)
38
 
39
- with st.container():
 
40
  custom_css = """
41
  <style>
42
  .my-container-table, p.my-container-text {
@@ -75,7 +84,7 @@ def show_dataset_examples(display_name):
75
 
76
  st.text("")
77
 
78
- st.divider()
79
 
80
 
81
  def show_examples(category_name, dataset_name, model_lists, display_model_names):
 
1
  import streamlit as st
2
  import datasets
3
  import numpy as np
4
+ import io
5
+ import soundfile as sf
6
 
7
  import html
8
 
 
21
  st.markdown(f'##### Example-{index+1}')
22
  col1, col2 = st.columns([0.3, 0.7], vertical_alignment="center")
23
 
24
+ with col1:
25
+ # Convert the NumPy array to a WAV file in memory
26
+ bytes_io = io.BytesIO()
27
+ sf.write(bytes_io, dataset[index]['context']['audio']['array'], dataset[index]['context']['audio']['sampling_rate'], format='WAV')
28
+ bytes_io.seek(0)
29
+ # Play audio in Streamlit
30
+ st.audio(bytes_io, format='audio/wav')
31
+ # st.audio(f'{sample_folder}/sample_{index}.wav', format="audio/wav")
32
+
33
  if dataset_name in ['CN-College-Listen-MCQ-Test', 'DREAM-TTS-MCQ-Test']:
34
 
35
  choices = dataset[index]['other_attributes']['choices']
 
44
 
45
  question_text = html.escape(question_text)
46
 
47
+ # with st.container():
48
+ with col2:
49
  custom_css = """
50
  <style>
51
  .my-container-table, p.my-container-text {
 
84
 
85
  st.text("")
86
 
87
+ st.divider()
88
 
89
 
90
  def show_examples(category_name, dataset_name, model_lists, display_model_names):