Spaces:
Build error
Build error
File size: 8,654 Bytes
25dc22a 9fa8261 25dc22a ee0b512 25dc22a 05d3c6a 25dc22a 05d3c6a 25dc22a 05d3c6a 25dc22a 1a000e2 25dc22a 05d3c6a 1a000e2 05d3c6a 25dc22a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | import csv
import gradio as gr
import os
import time
import os
import pandas as pd
app = None
os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
CURR_BASE_DIR = os.getcwd()
BASE_AUDIOS_DIR = os.path.join(os.getcwd(), "results")
BASE_VIDEO_DIR = BASE_AUDIOS_DIR
should_stop = False
current_process = None
if not os.path.exists(BASE_AUDIOS_DIR):
os.makedirs(BASE_AUDIOS_DIR)
custom_css = """
.gradio-container{
background-color: unset;
}
input, textarea {
font-family: 'Noto Naskh Arabic', 'Arial', sans-serif !important;
}
.large_text input{
font-size:20px !important
}
.tab-container button{
font-weight: bold !important;
}
.tabs{
gap:0px !important;
}
.tabitem{
padding:0px !important;
}
button.secondary:hover{
background-color:steelblue !important;
color:white;
}
.tab-container button {
font-size:20px !important;
}
.tabitem{
padding-top:0px !important;
}
#tool-header{
padding:20px 0px 20px 0px !important;
}
#tool-header h1{
display: flex;
align-items: center;
}
#tool-header img{
width: 80px;
display: inline-block;
margin-right: 10px;
border-radius: 5px;
}
"""
def natural_sort_key(file_name):
if ".DS_Store" in file_name:
return 0
return int(file_name.split("_")[1])
def get_data(folders_list, language="msa"):
results_csv_df = pd.read_csv(f"{CURR_BASE_DIR}/results/{language}/Ar_{language}_TTS_benchmark.csv")
data_map = {}
try:
for folder_name in folders_list:
full_audio_folder_path = os.path.join(BASE_AUDIOS_DIR,language ,folder_name)
if not os.path.exists(full_audio_folder_path):
print(f"Folder not found: {full_audio_folder_path}")
continue
if folder_name not in data_map:
data_map[folder_name] = []
##get all wavs and mp3s from full_audio_folder_path
for file in sorted(os.listdir(full_audio_folder_path), key=natural_sort_key):
if ".DS_Store" in file:
continue
if file.endswith(".wav") or file.endswith(".mp3"):
abs_path = os.path.join(full_audio_folder_path, file)
data_map[folder_name].append(abs_path)
final_df = pd.DataFrame(columns=["Text"].extend(folders_list))
final_df["Text"] = results_csv_df["Text"]
cache_random_hash = str(time.time())
for folder_name in data_map:
folder_files_list = data_map[folder_name]
formatted_column = pd.Series(folder_files_list).apply(
lambda file_path: f'<audio controls src="/gradio_api/file={file_path}?h={cache_random_hash}" type="audio/mpeg" style="width: 100%;"></audio>'
)
## append column to dataframe
final_df[folder_name] = formatted_column
return final_df
except Exception as e:
print(f"An error occurred: {e}")
gr.Warning(f"An error occurred: {e}")
raise e
with gr.Blocks(css=custom_css) as app:
gr.HTML(
f"""<h1><img src='/gradio_api/file={CURR_BASE_DIR}/images/silma-logo.png'/>Open-source Arabic TTS Benchmark</h1>
<br>
<p style="font-size:16px">
This benchmark represents a foundational step by <a href="https://silma.ai">SILMA.AI</a> towards establishing a high-quality benchmark for open-source Arabic TTS models. We have found that standard quantitative metrics (such as WER, CER, SIM, and UTMOS) are often insufficient for accurately capturing the nuances of Arabic speech. Consequently, for this release we have prioritized direct auditory assessment, allowing listeners to evaluate the naturalness and quality of the models themselves. More advanced releases will follow as we develop the necessary technology.
You can also check our <a href="https://huggingface.co/spaces/silma-ai/arabic-tts-benchmark" target="blank">Commercial Arabic TTS Benchmark</a>
</p>
<p>
Note: To make the benchmark more manageable, we have excluded models that require Tashkeel, as well as those based on old architectures
</p
""",
elem_id="tool-header"
)
with gr.Tabs():
with gr.TabItem("Modern Standard Arabic (MSA)"):
folders_list = ["habibi_specialized","xtts"]
df_header = ["Text","Habibi MSA Specialized","Coqui (XTTS)"]
data_df = get_data(folders_list, language="msa")
data_df.columns = df_header
data_viewer = gr.Dataframe(
datatype=["html"]+(["html"] * len(folders_list)),
value=data_df,
column_widths=[200]+([200]*len(folders_list)),
wrap=True,
show_label=True,
show_row_numbers=True,
interactive=True,
elem_classes="data_viewer_dataframe",
show_search="search",
visible=True,
)
with gr.TabItem("EGY"):
folders_list = ["habibi","egtts","chatterbox_masri"]
df_header = ["Text","Habibi EGY Specialized","EGTTS V0.1","Chatterbox-Egyptian"]
data_df = get_data(folders_list, language="egy")
data_df.columns = df_header
data_viewer = gr.Dataframe(
datatype=["html"]+(["html"] * len(folders_list)),
value=data_df,
column_widths=[200,200,200,200,200],
wrap=True,
show_label=True,
show_row_numbers=True,
interactive=True,
elem_classes="data_viewer_dataframe",
show_search="search",
visible=True
)
with gr.TabItem("KSA"):
folders_list = ["habibi"]
df_header = ["Text","Habibi KSA Specialized"]
data_df = get_data(folders_list, language="ksa")
data_df.columns = df_header
data_viewer = gr.Dataframe(
datatype=["html"]+(["html"] * len(folders_list)),
value=data_df,
column_widths=[200,200,200,200,200],
wrap=True,
show_label=True,
show_row_numbers=True,
interactive=True,
elem_classes="data_viewer_dataframe",
show_search="search",
visible=True
)
with gr.TabItem("UAE"):
folders_list = ["habibi"]
df_header = ["Text","Habibi UAE Specialized"]
data_df = get_data(folders_list, language="uae")
data_df.columns = df_header
data_viewer = gr.Dataframe(
datatype=["html"]+(["html"] * len(folders_list)),
value=data_df,
column_widths=[200,200,200,200,200],
wrap=True,
show_label=True,
show_row_numbers=True,
interactive=True,
elem_classes="data_viewer_dataframe",
show_search="search",
visible=True
)
with gr.Row():
## add link for each model
with gr.Column():
gr.Markdown("Benchmark model links:")
gr.Markdown("""
- <a href="https://huggingface.co/SWivid/Habibi-TTS" target="_blank">Habibi-TTS</a>
- <a href="https://huggingface.co/coqui/XTTS-v2" target="_blank">XTTS-v2</a>
- <a href="https://huggingface.co/OmarSamir/EGTTS-V0.1" target="_blank">EGTTS-v0.1</a>
- <a href="https://huggingface.co/oddadmix/chatterbox-egyptian-v0" target="_blank">Chatterbox-Egyptian</a>
""")
with gr.Column():
gr.Markdown("Other models:")
gr.Markdown("""
- <a href="https://huggingface.co/IbrahimSalah/Arabic-F5-TTS-v2" target="_blank">Arabic-F5-TTS-v2</a>
- <a href="https://huggingface.co/IbrahimSalah/Arabic-TTS-Spark" target="_blank">Arabic-TTS-Spark</a>
- <a href="https://huggingface.co/MrEzzat/Spark_TTS_Arabic" target="_blank">Spark_TTS_Arabic</a>
""")
def main():
global app
print("Starting app...")
app.queue().launch(favicon_path="images/silma-favicon.png", allowed_paths=[CURR_BASE_DIR+"/images/",CURR_BASE_DIR+"/results/"])
if __name__ == "__main__":
main()
|