Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -348,7 +348,7 @@ def fetch_local_news():
|
|
348 |
api_key = os.environ['SERP_API']
|
349 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
350 |
response = requests.get(url)
|
351 |
-
if response.status_code == 200:
|
352 |
results = response.json().get("news_results", [])
|
353 |
news_html = """
|
354 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
@@ -509,7 +509,12 @@ def generate_audio_elevenlabs(text):
|
|
509 |
def generate_audio_parler_tts(text):
|
510 |
model_id = 'parler-tts/parler_tts_mini_v0.1'
|
511 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
512 |
-
|
|
|
|
|
|
|
|
|
|
|
513 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
514 |
|
515 |
description = "A female speaker with a slightly low-pitched voice delivers her words quite expressively, in a very confined sounding environment with clear audio quality. She speaks very fast."
|
|
|
348 |
api_key = os.environ['SERP_API']
|
349 |
url = f'https://serpapi.com/search.json?engine=google_news&q=birmingham headline&api_key={api_key}'
|
350 |
response = requests.get(url)
|
351 |
+
if response.status_code == 200):
|
352 |
results = response.json().get("news_results", [])
|
353 |
news_html = """
|
354 |
<h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Birmingham Today</h2>
|
|
|
509 |
def generate_audio_parler_tts(text):
|
510 |
model_id = 'parler-tts/parler_tts_mini_v0.1'
|
511 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
512 |
+
try:
|
513 |
+
model = ParlerTTSForConditionalGeneration.from_pretrained(model_id).to(device)
|
514 |
+
except torch.cuda.OutOfMemoryError:
|
515 |
+
print("CUDA out of memory. Switching to CPU.")
|
516 |
+
device = "cpu"
|
517 |
+
model = ParlerTTSForConditionalGeneration.from_pretrained(model_id).to(device)
|
518 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
519 |
|
520 |
description = "A female speaker with a slightly low-pitched voice delivers her words quite expressively, in a very confined sounding environment with clear audio quality. She speaks very fast."
|