Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
@@ -30,29 +30,4 @@ def process_large_text(text):
|
|
30 |
"""
|
31 |
chunks = split_text_into_chunks(text, chunk_size=1000)
|
32 |
generated_text = generate_lesson_from_chunks(chunks)
|
33 |
-
return generated_text
|
34 |
-
|
35 |
-
text_analysis.py
|
36 |
-
from transformers import pipeline
|
37 |
-
|
38 |
-
# Modeli bir kez yükleyip her seferinde yeniden yüklememek için global değişken kullanabiliriz.
|
39 |
-
pipe = pipeline("translation", model="google-t5/t5-base", device="cpu")
|
40 |
-
pipe.model.config.pad_token_id = pipe.tokenizer.eos_token_id # pad_token_id ayarı
|
41 |
-
|
42 |
-
def generate_lesson_from_transcript(doc_text):
|
43 |
-
"""
|
44 |
-
Metin girişinden ders anlatımı üretir ve çıktı olarak metin ile dosya döndürür.
|
45 |
-
"""
|
46 |
-
try:
|
47 |
-
generated_text = pipe(doc_text, max_length=100, truncation=True)[0]['generated_text']
|
48 |
-
output_path = "/tmp/generated_output.txt" # Web ortamında /tmp gibi geçici bir dizin kullanabilirsiniz
|
49 |
-
|
50 |
-
with open(output_path, "w") as file:
|
51 |
-
file.write(generated_text)
|
52 |
-
|
53 |
-
return generated_text, output_path
|
54 |
-
|
55 |
-
except Exception as e:
|
56 |
-
# Hata mesajını daha ayrıntılı yazdırabiliriz.
|
57 |
-
print(f"Bir hata oluştu: {str(e)}")
|
58 |
-
return "Bir hata oluştu", None
|
|
|
30 |
"""
|
31 |
chunks = split_text_into_chunks(text, chunk_size=1000)
|
32 |
generated_text = generate_lesson_from_chunks(chunks)
|
33 |
+
return generated_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|