🐛[bugfix] Model : 非対応言語の場合に文字起こし失敗の例外処理をパスするように修正

This commit is contained in:
misyaguziya
2024-12-19 15:19:38 +09:00
parent 4d2fd379a8
commit 309869c494

View File

@@ -58,12 +58,16 @@ class AudioTranscriber:
case "Google": case "Google":
confidences = [] confidences = []
for language, country in zip(languages, countries): for language, country in zip(languages, countries):
text, confidence = self.audio_recognizer.recognize_google( try:
audio_data, text, confidence = self.audio_recognizer.recognize_google(
language=transcription_lang[language][country][self.transcription_engine], audio_data,
with_confidence=True language=transcription_lang[language][country][self.transcription_engine],
) with_confidence=True
confidences.append({"confidence": confidence, "text": text, "language": language}) )
confidences.append({"confidence": confidence, "text": text, "language": language})
except Exception:
pass
result = max(confidences, key=lambda x: x["confidence"]) result = max(confidences, key=lambda x: x["confidence"])
case "Whisper": case "Whisper":