Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ speaker_embeddings = {
|
|
| 20 |
}
|
| 21 |
|
| 22 |
def getNews(search_key):
|
| 23 |
-
return requests.get ("https://newsapi.org/v2/everything?
|
| 24 |
|
| 25 |
def getHeadlines():
|
| 26 |
return requests.get ("https://newsapi.org/v2/top-headlines?country=us&apiKey=3bca07c913ec4703a23f6ba03e15b30b").content.decode("utf-8")
|
|
@@ -32,14 +32,14 @@ def predict(text, preset):
|
|
| 32 |
|
| 33 |
# text = getNews ()
|
| 34 |
# inputs = processor(text=text, return_tensors="pt")
|
| 35 |
-
inputs = processor(text=getNews(text), return_tensors="pt")
|
| 36 |
|
| 37 |
# limit input length
|
| 38 |
input_ids = inputs["input_ids"]
|
| 39 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
| 40 |
|
| 41 |
# cmu_us_awb_arctic-wav-arctic_a0002.npy
|
| 42 |
-
speaker_embedding = np.load('spkemb/
|
| 43 |
speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
|
| 44 |
speech = model.generate_speech(input_ids, speaker_embedding, vocoder=vocoder)
|
| 45 |
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
def getNews(search_key):
|
| 23 |
+
return requests.get ("https://newsapi.org/v2/everything?pagesize=3&apiKey=3bca07c913ec4703a23f6ba03e15b30b&q="+search_key).content.decode("utf-8")
|
| 24 |
|
| 25 |
def getHeadlines():
|
| 26 |
return requests.get ("https://newsapi.org/v2/top-headlines?country=us&apiKey=3bca07c913ec4703a23f6ba03e15b30b").content.decode("utf-8")
|
|
|
|
| 32 |
|
| 33 |
# text = getNews ()
|
| 34 |
# inputs = processor(text=text, return_tensors="pt")
|
| 35 |
+
inputs = processor(text=textwrap.shorten(getNews(text), width=250), return_tensors="pt")
|
| 36 |
|
| 37 |
# limit input length
|
| 38 |
input_ids = inputs["input_ids"]
|
| 39 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
| 40 |
|
| 41 |
# cmu_us_awb_arctic-wav-arctic_a0002.npy
|
| 42 |
+
speaker_embedding = np.load('spkemb/cmu_us_bdl_arctic-wav-arctic_a0009.npy')
|
| 43 |
speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
|
| 44 |
speech = model.generate_speech(input_ids, speaker_embedding, vocoder=vocoder)
|
| 45 |
|