From 6a27b1919781d72c011846dab952a6ad0e091cb1 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Tue, 25 Jun 2024 22:23:05 +0530 Subject: [PATCH] allow runing the project without azure and 11 labs keys --- README.md | 34 +++++++++++++------ .../text_to_speech_settings_widgets.py | 12 +++++-- recipes/VideoBots.py | 7 ++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 93a719aa9..e8a269e36 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,30 @@ * Run `./manage.py migrate` * Install the zbar library (`brew install zbar`) +### Create a google cloud / firebase account + +1. Create a [google cloud](https://console.cloud.google.com/) project +2. Create a [firebase project](https://console.firebase.google.com/) (using the same google cloud project) +3. Enable the following services: + - [Firestore](https://console.firebase.google.com/project/_/firestore/databases) + - [Authentication](https://console.firebase.google.com/project/_/authentication/users) + - [Speech-to-Text](https://console.cloud.google.com/marketplace/product/google/speech.googleapis.com) + - [Text-to-Speech](https://console.cloud.google.com/marketplace/product/google/texttospeech.googleapis.com) + - [Translation API](https://console.cloud.google.com/marketplace/product/google/translate.googleapis.com) + - [Google Drive API](https://console.cloud.google.com/apis/library/drive.googleapis.com) +4. Go to IAM, Create a service account with following roles: + - Cloud Datastore User + - Cloud Speech Administrator + - Cloud Translation API Admin + - Firebase Authentication Admin +5. Download the `serviceAccountKey.json` and save it to the project root. + +* Run tests to see if everything is working fine: + ``` + ./scripts/run-tests.sh + ``` + (If you run into issues with the number of open files, you can remove the limit with `ulimit -n unlimited`) + ## Run You can start all required processes in one command with Honcho: @@ -43,10 +67,6 @@ to run it. **Note:** the Celery worker must be manually restarted on code changes. You can do this by stopping and starting Honcho. -## To run any recipe - -* Save `serviceAccountKey.json` to project root - ## To run vespa (used for vector search) You need to install OrbStack or Docker Desktop for this to work. @@ -177,12 +197,6 @@ docker exec -it $cid poetry run ./manage.py runscript create_fixture docker exec -it $cid poetry run ./manage.py runscript upload_fixture ``` -Save the new fixture url in `scripts/run-tests.sh` and run the tests - - -```bash -./scripts/run-tests.sh -``` - To load the fixture on local db - ```bash diff --git a/daras_ai_v2/text_to_speech_settings_widgets.py b/daras_ai_v2/text_to_speech_settings_widgets.py index 4adb3ce64..50dc50b46 100644 --- a/daras_ai_v2/text_to_speech_settings_widgets.py +++ b/daras_ai_v2/text_to_speech_settings_widgets.py @@ -195,7 +195,10 @@ def openai_tts_settings(): def azure_tts_selector(): - voices = azure_tts_voices() + if settings.AZURE_SPEECH_KEY: + voices = azure_tts_voices() + else: + voices = {} st.selectbox( label=""" ###### Azure TTS Voice name @@ -208,7 +211,7 @@ def azure_tts_selector(): def azure_tts_settings(): voice_name = st.session_state.get("azure_voice_name") - if not voice_name: + if not voice_name or not settings.AZURE_SPEECH_KEY: return try: voice = azure_tts_voices()[voice_name] @@ -382,7 +385,10 @@ def elevenlabs_selector(page): Alternatively, you can use your own ElevenLabs API key by selecting the checkbox above. """ ) - voices = default_elevenlabs_voices() + if settings.ELEVEN_LABS_API_KEY: + voices = default_elevenlabs_voices() + else: + voices = {} page.request.session[SESSION_ELEVENLABS_API_KEY] = st.session_state.get( "elevenlabs_api_key" diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index d5c567147..49e89f8ca 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -14,7 +14,7 @@ from daras_ai.image_input import ( truncate_text_words, ) -from daras_ai_v2 import icons +from daras_ai_v2 import icons, settings from daras_ai_v2.asr import ( translation_model_selector, translation_language_selector, @@ -437,7 +437,10 @@ def render_form_v2(self): st.session_state.get("document_model"), ), ): - doc_model_descriptions = azure_form_recognizer_models() + if settings.AZURE_FORM_RECOGNIZER_KEY: + doc_model_descriptions = azure_form_recognizer_models() + else: + doc_model_descriptions = {} st.selectbox( f"{field_desc(self.RequestModel, 'document_model')}", key="document_model",