Spaces:
Build error
Build error
html output for listen
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ DEFAULT_LANGS = {'Igbo':'ibo','Yoruba':'yor','Hausa':'hau'}
|
|
| 22 |
repo = Repository(
|
| 23 |
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
| 24 |
)
|
| 25 |
-
|
| 26 |
|
| 27 |
os.makedirs(AUDIO_PATH,exist_ok=True)
|
| 28 |
|
|
@@ -74,7 +74,23 @@ def display_records():
|
|
| 74 |
langs=df['language'].values
|
| 75 |
audios = df['audio'].values
|
| 76 |
texts=df['text'].values
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
#return df
|
| 79 |
|
| 80 |
|
|
@@ -110,7 +126,7 @@ with block:
|
|
| 110 |
with gr.TabItem('Listen') as listen_tab:
|
| 111 |
gr.Markdown("Listen to the recordings contributed. You can find them [here](https://huggingface.co/datasets/chrisjay/crowd-speech-africa).")
|
| 112 |
listen = gr.Button("Listen")
|
| 113 |
-
listen.click(display_records,inputs=[],outputs
|
| 114 |
|
| 115 |
|
| 116 |
|
|
|
|
| 22 |
repo = Repository(
|
| 23 |
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
| 24 |
)
|
| 25 |
+
repo.git_pull()
|
| 26 |
|
| 27 |
os.makedirs(AUDIO_PATH,exist_ok=True)
|
| 28 |
|
|
|
|
| 74 |
langs=df['language'].values
|
| 75 |
audios = df['audio'].values
|
| 76 |
texts=df['text'].values
|
| 77 |
+
|
| 78 |
+
html = """<div>
|
| 79 |
+
<table style="width:100%;border=1;text-align: center">
|
| 80 |
+
<tr>
|
| 81 |
+
<th>language</th>
|
| 82 |
+
<th>audio</th>
|
| 83 |
+
<th>text</th>
|
| 84 |
+
</tr>"""
|
| 85 |
+
for lang, audio, text in zip(langs,audios,texts):
|
| 86 |
+
html+= f"""<tr>
|
| 87 |
+
<td>{lang}</td>
|
| 88 |
+
<td><audio controls><source src="{audio}" type="audio/wav"> </audio></td>
|
| 89 |
+
<td>{text}</td>
|
| 90 |
+
</tr>"""
|
| 91 |
+
html+="</table></div>"
|
| 92 |
+
return html
|
| 93 |
+
#return langs[0],audios[0],texts[0]
|
| 94 |
#return df
|
| 95 |
|
| 96 |
|
|
|
|
| 126 |
with gr.TabItem('Listen') as listen_tab:
|
| 127 |
gr.Markdown("Listen to the recordings contributed. You can find them [here](https://huggingface.co/datasets/chrisjay/crowd-speech-africa).")
|
| 128 |
listen = gr.Button("Listen")
|
| 129 |
+
listen.click(display_records,inputs=[],outputs=gr.outputs.HTML() )
|
| 130 |
|
| 131 |
|
| 132 |
|