None1145's picture
Update app.py
f1c3b31 verified
raw
history blame
1.62 kB
import pandas as pd
import gradio as gr
def compare_csv_files():
file1 = "fish-speech-1.5.csv"
file2 = "fish-speech-1.4.csv"
df1 = pd.read_csv(file1)
df2 = pd.read_csv(file2)
merged_df = pd.merge(df1, df2, on="SourceText", suffixes=("_1.5", "_1.4"))
merged_df["WordErrorRate_Diff"] = merged_df["WordErrorRate_1.5"] - merged_df["WordErrorRate_1.4"]
if merged_df["WordErrorRate_Diff"] > 0: merged_df["WordErrorRate_Diff"] = f"1.5 is stronger than 1.4 ({merged_df['WordErrorRate_Diff']})"
if merged_df["WordErrorRate_Diff"] < 0: merged_df["WordErrorRate_Diff"] = f"1.4 is stronger than 1.5 ({0 - merged_df['WordErrorRate_Diff']})"
if merged_df["WordErrorRate_Diff"] == 0: merged_df["WordErrorRate_Diff"] = f"1.4 is the same as 1.5 (0)"
if merged_df["CharacterErrorRate_Diff"] > 0: merged_df["CharacterErrorRate_Diff"] = f"1.5 is stronger than 1.4 ({merged_df['CharacterErrorRate_Diff']})"
if merged_df["CharacterErrorRate_Diff"] < 0: merged_df["CharacterErrorRate_Diff"] = f"1.4 is stronger than 1.5 ({0 - merged_df['CharacterErrorRate_Diff']})"
if merged_df["CharacterErrorRate_Diff"] == 0: merged_df["CharacterErrorRate_Diff"] = f"1.4 is the same as 1.5 (0)"
comparison = merged_df[[
"SourceText",
"WhisperText_1.5", "WordErrorRate_1.5", "CharacterErrorRate_1.5",
"WhisperText_1.4", "WordErrorRate_1.4", "CharacterErrorRate_1.4",
"WordErrorRate_Diff", "CharacterErrorRate_Diff"
]]
return comparison.to_html(index=False)
gr.Interface(
fn=compare_csv_files,
inputs=None,
outputs="html"
).launch()