Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
@@ -18,7 +18,6 @@ def generate_lesson_from_transcript(doc_text):
|
|
18 |
print(f"Bir hata oluştu: {str(e)}")
|
19 |
return "Bir hata oluştu", None
|
20 |
|
21 |
-
|
22 |
def split_text_into_chunks(text, chunk_size=1000):
|
23 |
words = text.split()
|
24 |
chunks = []
|
@@ -27,15 +26,17 @@ def split_text_into_chunks(text, chunk_size=1000):
|
|
27 |
chunks.append(chunk)
|
28 |
return chunks
|
29 |
|
30 |
-
|
31 |
def generate_lesson_from_chunks(chunks):
|
32 |
generated_texts = []
|
33 |
for chunk in chunks:
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
return ' '.join(generated_texts)
|
37 |
|
38 |
-
|
39 |
def process_large_text(text):
|
40 |
chunks = split_text_into_chunks(text, chunk_size=1000)
|
41 |
generated_text = generate_lesson_from_chunks(chunks)
|
|
|
18 |
print(f"Bir hata oluştu: {str(e)}")
|
19 |
return "Bir hata oluştu", None
|
20 |
|
|
|
21 |
def split_text_into_chunks(text, chunk_size=1000):
|
22 |
words = text.split()
|
23 |
chunks = []
|
|
|
26 |
chunks.append(chunk)
|
27 |
return chunks
|
28 |
|
|
|
29 |
def generate_lesson_from_chunks(chunks):
|
30 |
generated_texts = []
|
31 |
for chunk in chunks:
|
32 |
+
try:
|
33 |
+
generated_text = pipe(chunk, max_length=500, truncation=True)[0]['generated_text']
|
34 |
+
generated_texts.append(generated_text)
|
35 |
+
except Exception as e:
|
36 |
+
print(f"Error in chunk processing: {str(e)}")
|
37 |
+
continue # Hata durumunda işlemi sürdür
|
38 |
return ' '.join(generated_texts)
|
39 |
|
|
|
40 |
def process_large_text(text):
|
41 |
chunks = split_text_into_chunks(text, chunk_size=1000)
|
42 |
generated_text = generate_lesson_from_chunks(chunks)
|