Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,8 +23,12 @@ class MultiASRApp:
|
|
| 23 |
self.current_kind = None # "whisper" | "ctc"
|
| 24 |
|
| 25 |
self.available_models = [
|
|
|
|
|
|
|
| 26 |
"openai/whisper-small",
|
| 27 |
"openai/whisper-medium",
|
|
|
|
|
|
|
| 28 |
"ilsp/whisper_greek_dialect_of_lesbos",
|
| 29 |
"ilsp/xls-r-greek-cretan",
|
| 30 |
]
|
|
@@ -33,8 +37,7 @@ class MultiASRApp:
|
|
| 33 |
# Model detection
|
| 34 |
# ------------------------
|
| 35 |
def detect_model_kind(self, model_name):
|
| 36 |
-
|
| 37 |
-
if "xls-r" in name or "xlsr" in name:
|
| 38 |
return "ctc"
|
| 39 |
return "whisper"
|
| 40 |
|
|
@@ -122,7 +125,7 @@ class MultiASRApp:
|
|
| 122 |
self.current_kind = kind
|
| 123 |
return True
|
| 124 |
except Exception as e:
|
| 125 |
-
logger.error(e)
|
| 126 |
self.clear_model()
|
| 127 |
return False
|
| 128 |
|
|
@@ -147,7 +150,19 @@ class MultiASRApp:
|
|
| 147 |
if not self.load_model(model_name):
|
| 148 |
return "Σφάλμα φόρτωσης μοντέλου.", ""
|
| 149 |
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
text = result.get("text", "")
|
| 152 |
|
| 153 |
info = (
|
|
@@ -164,7 +179,7 @@ class MultiASRApp:
|
|
| 164 |
|
| 165 |
|
| 166 |
# ------------------------
|
| 167 |
-
# App
|
| 168 |
# ------------------------
|
| 169 |
app = MultiASRApp()
|
| 170 |
|
|
|
|
| 23 |
self.current_kind = None # "whisper" | "ctc"
|
| 24 |
|
| 25 |
self.available_models = [
|
| 26 |
+
"openai/whisper-tiny",
|
| 27 |
+
"openai/whisper-base",
|
| 28 |
"openai/whisper-small",
|
| 29 |
"openai/whisper-medium",
|
| 30 |
+
"openai/whisper-large-v2",
|
| 31 |
+
"openai/whisper-large-v3",
|
| 32 |
"ilsp/whisper_greek_dialect_of_lesbos",
|
| 33 |
"ilsp/xls-r-greek-cretan",
|
| 34 |
]
|
|
|
|
| 37 |
# Model detection
|
| 38 |
# ------------------------
|
| 39 |
def detect_model_kind(self, model_name):
|
| 40 |
+
if "xls-r" in model_name.lower() or "xlsr" in model_name.lower():
|
|
|
|
| 41 |
return "ctc"
|
| 42 |
return "whisper"
|
| 43 |
|
|
|
|
| 125 |
self.current_kind = kind
|
| 126 |
return True
|
| 127 |
except Exception as e:
|
| 128 |
+
logger.error(e, exc_info=True)
|
| 129 |
self.clear_model()
|
| 130 |
return False
|
| 131 |
|
|
|
|
| 150 |
if not self.load_model(model_name):
|
| 151 |
return "Σφάλμα φόρτωσης μοντέλου.", ""
|
| 152 |
|
| 153 |
+
# 🔒 FORCE GREEK FOR ALL WHISPER MODELS
|
| 154 |
+
if self.current_kind == "whisper":
|
| 155 |
+
result = self.pipe(
|
| 156 |
+
audio,
|
| 157 |
+
generate_kwargs={
|
| 158 |
+
"language": "greek",
|
| 159 |
+
"task": "transcribe",
|
| 160 |
+
},
|
| 161 |
+
)
|
| 162 |
+
else:
|
| 163 |
+
# XLS-R (CTC)
|
| 164 |
+
result = self.pipe(audio)
|
| 165 |
+
|
| 166 |
text = result.get("text", "")
|
| 167 |
|
| 168 |
info = (
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
# ------------------------
|
| 182 |
+
# Gradio App
|
| 183 |
# ------------------------
|
| 184 |
app = MultiASRApp()
|
| 185 |
|