Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,3 @@
|
|
| 1 |
-
try:
|
| 2 |
-
import versa
|
| 3 |
-
except ImportError:
|
| 4 |
-
from subprocess import call
|
| 5 |
-
with open('versa.sh', 'rb') as file:
|
| 6 |
-
script = file.read()
|
| 7 |
-
rc = call(script, shell=True)
|
| 8 |
|
| 9 |
import os
|
| 10 |
import shutil
|
|
@@ -16,27 +9,7 @@ import nltk
|
|
| 16 |
import numpy as np
|
| 17 |
import torch
|
| 18 |
from huggingface_hub import HfApi
|
| 19 |
-
|
| 20 |
-
from pyscripts.utils.dialog_eval.human_feedback import (
|
| 21 |
-
natural_vote1_last_response,
|
| 22 |
-
natural_vote2_last_response,
|
| 23 |
-
natural_vote3_last_response,
|
| 24 |
-
natural_vote4_last_response,
|
| 25 |
-
relevant_vote1_last_response,
|
| 26 |
-
relevant_vote2_last_response,
|
| 27 |
-
relevant_vote3_last_response,
|
| 28 |
-
relevant_vote4_last_response,
|
| 29 |
-
)
|
| 30 |
-
from pyscripts.utils.dialog_eval.LLM_Metrics import (
|
| 31 |
-
DialoGPT_perplexity,
|
| 32 |
-
bert_score,
|
| 33 |
-
perplexity,
|
| 34 |
-
vert,
|
| 35 |
-
)
|
| 36 |
-
from pyscripts.utils.dialog_eval.TTS_intelligibility import (
|
| 37 |
-
handle_espnet_TTS_intelligibility,
|
| 38 |
-
)
|
| 39 |
-
from pyscripts.utils.dialog_eval.TTS_speech_quality import TTS_psuedomos
|
| 40 |
|
| 41 |
from espnet2.sds.espnet_model import ESPnetSDSModelInterface
|
| 42 |
|
|
@@ -153,34 +126,7 @@ def handle_eval_selection(
|
|
| 153 |
"""
|
| 154 |
global LLM_response_arr
|
| 155 |
global total_response_arr
|
| 156 |
-
|
| 157 |
-
if option == "Latency":
|
| 158 |
-
text = (
|
| 159 |
-
f"ASR Latency: {latency_ASR:.2f}\n"
|
| 160 |
-
f"LLM Latency: {latency_LM:.2f}\n"
|
| 161 |
-
f"TTS Latency: {latency_TTS:.2f}"
|
| 162 |
-
)
|
| 163 |
-
yield (None, text)
|
| 164 |
-
elif option == "TTS Intelligibility":
|
| 165 |
-
yield (None, handle_espnet_TTS_intelligibility(TTS_audio_output, LLM_Output))
|
| 166 |
-
elif option == "TTS Speech Quality":
|
| 167 |
-
yield (None, TTS_psuedomos(TTS_audio_output))
|
| 168 |
-
elif option == "ASR WER":
|
| 169 |
-
yield (None, handle_espnet_ASR_WER(ASR_audio_output, ASR_transcript))
|
| 170 |
-
elif option == "Text Dialog Metrics":
|
| 171 |
-
yield (
|
| 172 |
-
None,
|
| 173 |
-
perplexity(LLM_Output.replace("\n", " "))
|
| 174 |
-
+ vert(LLM_response_arr)
|
| 175 |
-
+ bert_score(total_response_arr)
|
| 176 |
-
+ DialoGPT_perplexity(
|
| 177 |
-
ASR_transcript.replace("\n", " "), LLM_Output.replace("\n", " ")
|
| 178 |
-
),
|
| 179 |
-
)
|
| 180 |
-
elif option is None:
|
| 181 |
-
return
|
| 182 |
-
else:
|
| 183 |
-
raise ValueError(f"Unknown option: {option}")
|
| 184 |
|
| 185 |
|
| 186 |
def handle_eval_selection_E2E(
|
|
@@ -244,20 +190,7 @@ def handle_eval_selection_E2E(
|
|
| 244 |
"""
|
| 245 |
global LLM_response_arr
|
| 246 |
global total_response_arr
|
| 247 |
-
|
| 248 |
-
if option == "Latency":
|
| 249 |
-
text = f"Total Latency: {latency_TTS:.2f}"
|
| 250 |
-
yield (None, text)
|
| 251 |
-
elif option == "TTS Intelligibility":
|
| 252 |
-
yield (None, handle_espnet_TTS_intelligibility(TTS_audio_output, LLM_Output))
|
| 253 |
-
elif option == "TTS Speech Quality":
|
| 254 |
-
yield (None, TTS_psuedomos(TTS_audio_output))
|
| 255 |
-
elif option == "Text Dialog Metrics":
|
| 256 |
-
yield (None, perplexity(LLM_Output.replace("\n", " ")) + vert(LLM_response_arr))
|
| 257 |
-
elif option is None:
|
| 258 |
-
return
|
| 259 |
-
else:
|
| 260 |
-
raise ValueError(f"Unknown option: {option}")
|
| 261 |
|
| 262 |
|
| 263 |
def start_warmup():
|
|
@@ -789,198 +722,6 @@ with gr.Blocks(
|
|
| 789 |
None,
|
| 790 |
preprocess=False,
|
| 791 |
)
|
| 792 |
-
|
| 793 |
-
natural_vote1_last_response,
|
| 794 |
-
[],
|
| 795 |
-
[natural_response, ip_address] + natural_btn_list,
|
| 796 |
-
).then(
|
| 797 |
-
lambda *args: callback.flag(list(args)),
|
| 798 |
-
[
|
| 799 |
-
user_audio,
|
| 800 |
-
output_asr_text,
|
| 801 |
-
output_text,
|
| 802 |
-
output_audio,
|
| 803 |
-
output_audio1,
|
| 804 |
-
type_radio,
|
| 805 |
-
ASR_radio,
|
| 806 |
-
LLM_radio,
|
| 807 |
-
radio,
|
| 808 |
-
E2Eradio,
|
| 809 |
-
natural_response,
|
| 810 |
-
diversity_response,
|
| 811 |
-
ip_address,
|
| 812 |
-
],
|
| 813 |
-
None,
|
| 814 |
-
preprocess=False,
|
| 815 |
-
)
|
| 816 |
-
natural_btn2.click(
|
| 817 |
-
natural_vote2_last_response,
|
| 818 |
-
[],
|
| 819 |
-
[natural_response, ip_address] + natural_btn_list,
|
| 820 |
-
).then(
|
| 821 |
-
lambda *args: callback.flag(list(args)),
|
| 822 |
-
[
|
| 823 |
-
user_audio,
|
| 824 |
-
output_asr_text,
|
| 825 |
-
output_text,
|
| 826 |
-
output_audio,
|
| 827 |
-
output_audio1,
|
| 828 |
-
type_radio,
|
| 829 |
-
ASR_radio,
|
| 830 |
-
LLM_radio,
|
| 831 |
-
radio,
|
| 832 |
-
E2Eradio,
|
| 833 |
-
natural_response,
|
| 834 |
-
diversity_response,
|
| 835 |
-
ip_address,
|
| 836 |
-
],
|
| 837 |
-
None,
|
| 838 |
-
preprocess=False,
|
| 839 |
-
)
|
| 840 |
-
natural_btn3.click(
|
| 841 |
-
natural_vote3_last_response,
|
| 842 |
-
[],
|
| 843 |
-
[natural_response, ip_address] + natural_btn_list,
|
| 844 |
-
).then(
|
| 845 |
-
lambda *args: callback.flag(list(args)),
|
| 846 |
-
[
|
| 847 |
-
user_audio,
|
| 848 |
-
output_asr_text,
|
| 849 |
-
output_text,
|
| 850 |
-
output_audio,
|
| 851 |
-
output_audio1,
|
| 852 |
-
type_radio,
|
| 853 |
-
ASR_radio,
|
| 854 |
-
LLM_radio,
|
| 855 |
-
radio,
|
| 856 |
-
E2Eradio,
|
| 857 |
-
natural_response,
|
| 858 |
-
diversity_response,
|
| 859 |
-
ip_address,
|
| 860 |
-
],
|
| 861 |
-
None,
|
| 862 |
-
preprocess=False,
|
| 863 |
-
)
|
| 864 |
-
natural_btn4.click(
|
| 865 |
-
natural_vote4_last_response,
|
| 866 |
-
[],
|
| 867 |
-
[natural_response, ip_address] + natural_btn_list,
|
| 868 |
-
).then(
|
| 869 |
-
lambda *args: callback.flag(list(args)),
|
| 870 |
-
[
|
| 871 |
-
user_audio,
|
| 872 |
-
output_asr_text,
|
| 873 |
-
output_text,
|
| 874 |
-
output_audio,
|
| 875 |
-
output_audio1,
|
| 876 |
-
type_radio,
|
| 877 |
-
ASR_radio,
|
| 878 |
-
LLM_radio,
|
| 879 |
-
radio,
|
| 880 |
-
E2Eradio,
|
| 881 |
-
natural_response,
|
| 882 |
-
diversity_response,
|
| 883 |
-
ip_address,
|
| 884 |
-
],
|
| 885 |
-
None,
|
| 886 |
-
preprocess=False,
|
| 887 |
-
)
|
| 888 |
-
relevant_btn1.click(
|
| 889 |
-
relevant_vote1_last_response,
|
| 890 |
-
[],
|
| 891 |
-
[diversity_response, ip_address] + relevant_btn_list,
|
| 892 |
-
).then(
|
| 893 |
-
lambda *args: callback.flag(list(args)),
|
| 894 |
-
[
|
| 895 |
-
user_audio,
|
| 896 |
-
output_asr_text,
|
| 897 |
-
output_text,
|
| 898 |
-
output_audio,
|
| 899 |
-
output_audio1,
|
| 900 |
-
type_radio,
|
| 901 |
-
ASR_radio,
|
| 902 |
-
LLM_radio,
|
| 903 |
-
radio,
|
| 904 |
-
E2Eradio,
|
| 905 |
-
natural_response,
|
| 906 |
-
diversity_response,
|
| 907 |
-
ip_address,
|
| 908 |
-
],
|
| 909 |
-
None,
|
| 910 |
-
preprocess=False,
|
| 911 |
-
)
|
| 912 |
-
relevant_btn2.click(
|
| 913 |
-
relevant_vote2_last_response,
|
| 914 |
-
[],
|
| 915 |
-
[diversity_response, ip_address] + relevant_btn_list,
|
| 916 |
-
).then(
|
| 917 |
-
lambda *args: callback.flag(list(args)),
|
| 918 |
-
[
|
| 919 |
-
user_audio,
|
| 920 |
-
output_asr_text,
|
| 921 |
-
output_text,
|
| 922 |
-
output_audio,
|
| 923 |
-
output_audio1,
|
| 924 |
-
type_radio,
|
| 925 |
-
ASR_radio,
|
| 926 |
-
LLM_radio,
|
| 927 |
-
radio,
|
| 928 |
-
E2Eradio,
|
| 929 |
-
natural_response,
|
| 930 |
-
diversity_response,
|
| 931 |
-
ip_address,
|
| 932 |
-
],
|
| 933 |
-
None,
|
| 934 |
-
preprocess=False,
|
| 935 |
-
)
|
| 936 |
-
relevant_btn3.click(
|
| 937 |
-
relevant_vote3_last_response,
|
| 938 |
-
[],
|
| 939 |
-
[diversity_response, ip_address] + relevant_btn_list,
|
| 940 |
-
).then(
|
| 941 |
-
lambda *args: callback.flag(list(args)),
|
| 942 |
-
[
|
| 943 |
-
user_audio,
|
| 944 |
-
output_asr_text,
|
| 945 |
-
output_text,
|
| 946 |
-
output_audio,
|
| 947 |
-
output_audio1,
|
| 948 |
-
type_radio,
|
| 949 |
-
ASR_radio,
|
| 950 |
-
LLM_radio,
|
| 951 |
-
radio,
|
| 952 |
-
E2Eradio,
|
| 953 |
-
natural_response,
|
| 954 |
-
diversity_response,
|
| 955 |
-
ip_address,
|
| 956 |
-
],
|
| 957 |
-
None,
|
| 958 |
-
preprocess=False,
|
| 959 |
-
)
|
| 960 |
-
relevant_btn4.click(
|
| 961 |
-
relevant_vote4_last_response,
|
| 962 |
-
[],
|
| 963 |
-
[diversity_response, ip_address] + relevant_btn_list,
|
| 964 |
-
).then(
|
| 965 |
-
lambda *args: callback.flag(list(args)),
|
| 966 |
-
[
|
| 967 |
-
user_audio,
|
| 968 |
-
output_asr_text,
|
| 969 |
-
output_text,
|
| 970 |
-
output_audio,
|
| 971 |
-
output_audio1,
|
| 972 |
-
type_radio,
|
| 973 |
-
ASR_radio,
|
| 974 |
-
LLM_radio,
|
| 975 |
-
radio,
|
| 976 |
-
E2Eradio,
|
| 977 |
-
natural_response,
|
| 978 |
-
diversity_response,
|
| 979 |
-
ip_address,
|
| 980 |
-
],
|
| 981 |
-
None,
|
| 982 |
-
preprocess=False,
|
| 983 |
-
)
|
| 984 |
demo.queue(max_size=10, default_concurrency_limit=1)
|
| 985 |
-
demo.launch(share=True)
|
| 986 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
import shutil
|
|
|
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
from huggingface_hub import HfApi
|
| 12 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
from espnet2.sds.espnet_model import ESPnetSDSModelInterface
|
| 15 |
|
|
|
|
| 126 |
"""
|
| 127 |
global LLM_response_arr
|
| 128 |
global total_response_arr
|
| 129 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
def handle_eval_selection_E2E(
|
|
|
|
| 190 |
"""
|
| 191 |
global LLM_response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