Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from datasets import load_dataset
|
|
| 4 |
from duckduckgo_search import DDGS
|
| 5 |
from newspaper import Article
|
| 6 |
import scipy
|
|
|
|
| 7 |
from transformers import (
|
| 8 |
MT5Tokenizer,
|
| 9 |
AdamW,
|
|
@@ -22,7 +23,7 @@ class Webapp:
|
|
| 22 |
self.DEVICE = 0 if torch.cuda.is_available() else "cpu"
|
| 23 |
self.REF_MODEL = 'google/mt5-small'
|
| 24 |
self.MODEL_NAME = 'Ahmedasd/arabic-summarization-hhh-100-batches'
|
| 25 |
-
self.model_id = "openai/whisper-
|
| 26 |
self.tts_model_id = "SeyedAli/Arabic-Speech-synthesis"
|
| 27 |
self.tts_model = VitsModel.from_pretrained(self.tts_model_id).to(self.DEVICE)
|
| 28 |
self.tts_tokenizer = AutoTokenizer.from_pretrained(self.tts_model_id)
|
|
@@ -57,7 +58,14 @@ class Webapp:
|
|
| 57 |
urls = [r['url'] for r in results]
|
| 58 |
print('successful connection!')
|
| 59 |
except Exception as error:
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
articles = []
|
| 63 |
for url in urls:
|
|
|
|
| 4 |
from duckduckgo_search import DDGS
|
| 5 |
from newspaper import Article
|
| 6 |
import scipy
|
| 7 |
+
import random
|
| 8 |
from transformers import (
|
| 9 |
MT5Tokenizer,
|
| 10 |
AdamW,
|
|
|
|
| 23 |
self.DEVICE = 0 if torch.cuda.is_available() else "cpu"
|
| 24 |
self.REF_MODEL = 'google/mt5-small'
|
| 25 |
self.MODEL_NAME = 'Ahmedasd/arabic-summarization-hhh-100-batches'
|
| 26 |
+
self.model_id = "openai/whisper-tiny"
|
| 27 |
self.tts_model_id = "SeyedAli/Arabic-Speech-synthesis"
|
| 28 |
self.tts_model = VitsModel.from_pretrained(self.tts_model_id).to(self.DEVICE)
|
| 29 |
self.tts_tokenizer = AutoTokenizer.from_pretrained(self.tts_model_id)
|
|
|
|
| 58 |
urls = [r['url'] for r in results]
|
| 59 |
print('successful connection!')
|
| 60 |
except Exception as error:
|
| 61 |
+
examples = ['https://www.bbc.com/arabic/media-65576589',
|
| 62 |
+
'https://www.bbc.com/arabic/articles/czr8dk93231o',
|
| 63 |
+
'https://www.bbc.com/arabic/articles/c0jyd2yweplo',
|
| 64 |
+
'https://www.bbc.com/arabic/articles/cnd8wwdyyzko',
|
| 65 |
+
'https://www.bbc.com/arabic/articles/c3gyxymp0z1o',
|
| 66 |
+
'https://www.bbc.com/arabic/articles/c3g28kl8zj4o'
|
| 67 |
+
]
|
| 68 |
+
urls = [random.choice(examples)]
|
| 69 |
|
| 70 |
articles = []
|
| 71 |
for url in urls:
|