Update app.py
Browse files
app.py
CHANGED
@@ -32,9 +32,13 @@ try:
|
|
32 |
logger.info("Successfully loaded RagRetriever with trust_remote_code=True")
|
33 |
except ValueError as e:
|
34 |
logger.error(f"Error loading RagRetriever: {e}")
|
35 |
-
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
def transcribe_audio(audio_path, language="ru"):
|
40 |
speech, rate = librosa.load(audio_path, sr=16000)
|
@@ -45,6 +49,8 @@ def transcribe_audio(audio_path, language="ru"):
|
|
45 |
return transcription
|
46 |
|
47 |
def translate_and_summarize(text):
|
|
|
|
|
48 |
inputs = rag_tokenizer(text, return_tensors="pt")
|
49 |
input_ids = inputs["input_ids"]
|
50 |
attention_mask = inputs["attention_mask"]
|
|
|
32 |
logger.info("Successfully loaded RagRetriever with trust_remote_code=True")
|
33 |
except ValueError as e:
|
34 |
logger.error(f"Error loading RagRetriever: {e}")
|
35 |
+
rag_retriever = None
|
36 |
|
37 |
+
if rag_retriever is not None:
|
38 |
+
rag_model = RagSequenceForGeneration.from_pretrained(rag_model_name, retriever=rag_retriever)
|
39 |
+
else:
|
40 |
+
logger.error("RagRetriever is not available, unable to proceed with loading RAG model.")
|
41 |
+
st.error("RagRetriever is not available, unable to proceed with loading RAG model.")
|
42 |
|
43 |
def transcribe_audio(audio_path, language="ru"):
|
44 |
speech, rate = librosa.load(audio_path, sr=16000)
|
|
|
49 |
return transcription
|
50 |
|
51 |
def translate_and_summarize(text):
|
52 |
+
if rag_retriever is None:
|
53 |
+
return ["Translation and summarization feature is not available due to RAG retriever loading issue."]
|
54 |
inputs = rag_tokenizer(text, return_tensors="pt")
|
55 |
input_ids = inputs["input_ids"]
|
56 |
attention_mask = inputs["attention_mask"]
|