diff --git a/daras_ai/image_input.py b/daras_ai/image_input.py
index 0d9530f22..5e61fcba9 100644
--- a/daras_ai/image_input.py
+++ b/daras_ai/image_input.py
@@ -11,6 +11,7 @@
from furl import furl
from daras_ai_v2 import settings
+from daras_ai_v2.exceptions import UserError
def resize_img_pad(img_bytes: bytes, size: tuple[int, int]) -> bytes:
@@ -90,7 +91,7 @@ def bytes_to_cv2_img(img_bytes: bytes, greyscale=False) -> np.ndarray:
flags = cv2.IMREAD_COLOR
img_cv2 = cv2.imdecode(np.frombuffer(img_bytes, dtype=np.uint8), flags=flags)
if not img_exists(img_cv2):
- raise ValueError("Bad Image")
+ raise UserError("Bad Image")
return img_cv2
diff --git a/recipes/TextToSpeech.py b/recipes/TextToSpeech.py
index 7494c992d..f56c3957d 100644
--- a/recipes/TextToSpeech.py
+++ b/recipes/TextToSpeech.py
@@ -12,7 +12,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 raise_for_status
+from daras_ai_v2.exceptions import raise_for_status, 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 (
@@ -254,13 +254,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()
- ), """
- Please purchase Gooey.AI credits to use ElevenLabs voices here.
- """
+ ):
+ 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)
diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py
index 4c5d2e19b..410416342 100644
--- a/recipes/VideoBots.py
+++ b/recipes/VideoBots.py
@@ -621,12 +621,14 @@ def additional_notes(self):
def run(self, state: dict) -> typing.Iterator[str | None]:
request: VideoBotsPage.RequestModel = self.RequestModel.parse_obj(state)
- if state.get("tts_provider") == TextToSpeechProviders.ELEVEN_LABS.name:
- assert (
- self.is_current_user_paying() or self.is_current_user_admin()
- ), """
+ if state.get("tts_provider") == TextToSpeechProviders.ELEVEN_LABS.name and not (
+ self.is_current_user_paying() or self.is_current_user_admin()
+ ):
+ raise UserError(
+ """
Please purchase Gooey.AI credits to use ElevenLabs voices here.
"""
+ )
user_input = request.input_prompt.strip()
if not (user_input or request.input_images or request.input_documents):