Skip to content

Commit

Permalink
allow runing the project without azure and 11 labs keys
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jun 25, 2024
1 parent 5543c8e commit 6a27b19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions daras_ai_v2/text_to_speech_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 6a27b19

Please sign in to comment.