Print language detection related message to debug_tts
This commit is contained in:
1 parent
f21f828ab5
commit
53e632b70b
1 file changed
+4
-4
+4
-4
@@ -2127,18 +2127,18 @@ def detect_language(text: str) -> str:
|
|||||||
try:
|
try:
|
||||||
# Detect the language of the text
|
# Detect the language of the text
|
||||||
detected_lang = detect(text)
|
detected_lang = detect(text)
|
||||||
print_message(f"Detected language: {detected_lang}", "debug", "LANG_DETECTION")
|
print_message(f"Detected language: {detected_lang}",
|
||||||
|
message_type="debug_tts")
|
||||||
|
|
||||||
# Use the fallback language if the detected one is unsupported
|
# Use the fallback language if the detected one is unsupported
|
||||||
fallback_lang = LANG_FALLBACKS.get(detected_lang, "en") # Default fallback: French
|
fallback_lang = LANG_FALLBACKS.get(detected_lang, "en") # Default fallback: French
|
||||||
if detected_lang != fallback_lang:
|
if detected_lang != fallback_lang:
|
||||||
print_message(f"Language '{detected_lang}' not supported, using fallback '{fallback_lang}'", "warn",
|
print_message(f"Language '{detected_lang}' not supported, using fallback '{fallback_lang}'", message_type="debug_tts")
|
||||||
"LANG_FALLBACK")
|
|
||||||
|
|
||||||
return fallback_lang
|
return fallback_lang
|
||||||
except LangDetectException as e:
|
except LangDetectException as e:
|
||||||
# Handle errors in language detection
|
# Handle errors in language detection
|
||||||
print_message(f"Language detection error: {str(e)}", "error", "LANG_DETECTION")
|
print_message(f"Language detection error: {str(e)}", message_type="debug_tts")
|
||||||
raise ValueError("Could not detect language")
|
raise ValueError("Could not detect language")
|
||||||
|
|
||||||
@app.post("/api/tts-generate", response_class=JSONResponse)
|
@app.post("/api/tts-generate", response_class=JSONResponse)
|
||||||
|
|||||||
Reference in new issue
Block a user