From 8cec0e6ae91076adef974141ec337b98b0f5b341 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:08:01 +0530 Subject: [PATCH] Raise UserError for Eleven Labs credits error --- recipes/TextToSpeech.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/TextToSpeech.py b/recipes/TextToSpeech.py index 1f67fbe20..563b2cd81 100644 --- a/recipes/TextToSpeech.py +++ b/recipes/TextToSpeech.py @@ -1,4 +1,3 @@ -import datetime import json import time import typing @@ -12,6 +11,7 @@ from daras_ai.image_input import upload_file_from_bytes, storage_blob_for from daras_ai_v2 import settings from daras_ai_v2.base import BasePage +from daras_ai_v2.exceptions import UserError from daras_ai_v2.gpu_server import GpuEndpoints, call_celery_task_outfile from daras_ai_v2.loom_video_widget import youtube_video from daras_ai_v2.text_to_speech_settings_widgets import ( @@ -257,13 +257,16 @@ def run(self, state: dict): case TextToSpeechProviders.ELEVEN_LABS: xi_api_key, is_custom_key = self._get_elevenlabs_api_key(state) - assert ( + if not ( is_custom_key or self.is_current_user_paying() or self.is_current_user_admin() - ), """ + ): + raise UserError( + """ Please purchase Gooey.AI credits to use ElevenLabs voices here. """ + ) voice_model = self._get_elevenlabs_voice_model(state) voice_id = self._get_elevenlabs_voice_id(state)