Skip to content

Commit

Permalink
Raise UserError for Eleven Labs credits error
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Jan 1, 2024
1 parent d816193 commit 8cec0e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions recipes/TextToSpeech.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import json
import time
import typing
Expand All @@ -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 (
Expand Down Expand Up @@ -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 <a href="/account">here</a>.
"""
)

voice_model = self._get_elevenlabs_voice_model(state)
voice_id = self._get_elevenlabs_voice_id(state)
Expand Down

0 comments on commit 8cec0e6

Please sign in to comment.