Update app.py
Browse files
app.py
CHANGED
|
@@ -15,8 +15,9 @@ def load_models():
|
|
| 15 |
|
| 16 |
st.session_state.translation_tokenizer = AutoTokenizer.from_pretrained("botisan-ai/mt5-translate-yue-zh")
|
| 17 |
st.session_state.translation_model = AutoModelForSeq2SeqLM.from_pretrained("botisan-ai/mt5-translate-yue-zh")
|
| 18 |
-
|
| 19 |
-
st.session_state.rating_pipe = pipeline("
|
|
|
|
| 20 |
|
| 21 |
def transcribe_audio(audio_path):
|
| 22 |
pipe = st.session_state.transcription_pipe
|
|
@@ -31,7 +32,8 @@ def translate_text(text):
|
|
| 31 |
|
| 32 |
def rate_quality(text):
|
| 33 |
result = st.session_state.rating_pipe(text)[0]
|
| 34 |
-
label = result["label"]
|
|
|
|
| 35 |
label_map = {"負面": "Poor", "中性": "Average", "正面": "Good"}
|
| 36 |
return label_map.get(label, "Unknown")
|
| 37 |
|
|
|
|
| 15 |
|
| 16 |
st.session_state.translation_tokenizer = AutoTokenizer.from_pretrained("botisan-ai/mt5-translate-yue-zh")
|
| 17 |
st.session_state.translation_model = AutoModelForSeq2SeqLM.from_pretrained("botisan-ai/mt5-translate-yue-zh")
|
| 18 |
+
|
| 19 |
+
st.session_state.rating_pipe = pipeline("sentiment-analysis", model="uer/roberta-base-finetuned-dianping-chinese")
|
| 20 |
+
# st.session_state.rating_pipe = pipeline("text-classification", model="jackietung/bert-base-chinese-finetuned-sentiment")
|
| 21 |
|
| 22 |
def transcribe_audio(audio_path):
|
| 23 |
pipe = st.session_state.transcription_pipe
|
|
|
|
| 32 |
|
| 33 |
def rate_quality(text):
|
| 34 |
result = st.session_state.rating_pipe(text)[0]
|
| 35 |
+
label = result["label"].split("(")[0].strip().lower()
|
| 36 |
+
# label = result["label"]
|
| 37 |
label_map = {"負面": "Poor", "中性": "Average", "正面": "Good"}
|
| 38 |
return label_map.get(label, "Unknown")
|
| 39 |
|