not-lain commited on
Commit
28b69ba
1 Parent(s): b67fe1a

changed reloading envirenmental variables method

Browse files
Files changed (2) hide show
  1. app.py +6 -6
  2. requirements.txt +1 -0
app.py CHANGED
@@ -6,7 +6,7 @@ import torchaudio
6
  import gradio as gr
7
  import requests
8
  import json
9
- from decouple import Config
10
  from transformers import AutoProcessor, SeamlessM4TModel
11
 
12
  from lang_list import (
@@ -18,7 +18,7 @@ from lang_list import (
18
  LANG_TO_SPKR_ID,
19
  )
20
 
21
- config = Config('.env')
22
 
23
  DEFAULT_TARGET_LANGUAGE = "English"
24
  AUDIO_SAMPLE_RATE = 16000.0
@@ -74,7 +74,7 @@ def predict(
74
 
75
  def process_image_with_openai(image):
76
  image_data = convert_image_to_required_format(image)
77
- openai_api_key = config('OPENAI_API_KEY') # Make sure to have this in your .env file
78
 
79
  data_payload = {
80
  "model": "gpt-4-vision-preview",
@@ -106,9 +106,9 @@ def query_vectara(text):
106
  user_message = text
107
 
108
  # Read authentication parameters from the .env file
109
- CUSTOMER_ID = config('CUSTOMER_ID')
110
- CORPUS_ID = config('CORPUS_ID')
111
- API_KEY = config('API_KEY')
112
 
113
  # Define the headers
114
  api_key_header = {
 
6
  import gradio as gr
7
  import requests
8
  import json
9
+ import dotenv
10
  from transformers import AutoProcessor, SeamlessM4TModel
11
 
12
  from lang_list import (
 
18
  LANG_TO_SPKR_ID,
19
  )
20
 
21
+ dotenv.load_dotenv()
22
 
23
  DEFAULT_TARGET_LANGUAGE = "English"
24
  AUDIO_SAMPLE_RATE = 16000.0
 
74
 
75
  def process_image_with_openai(image):
76
  image_data = convert_image_to_required_format(image)
77
+ openai_api_key = os.getenv('OPENAI_API_KEY') # Make sure to have this in your .env file
78
 
79
  data_payload = {
80
  "model": "gpt-4-vision-preview",
 
106
  user_message = text
107
 
108
  # Read authentication parameters from the .env file
109
+ CUSTOMER_ID = os.getenv('CUSTOMER_ID')
110
+ CORPUS_ID = os.getenv('CORPUS_ID')
111
+ API_KEY = os.getenv('API_KEY')
112
 
113
  # Define the headers
114
  api_key_header = {
requirements.txt CHANGED
@@ -3,3 +3,4 @@ gradio
3
  git+https://github.com/huggingface/transformers
4
  torchaudio==2.0.2
5
  sentencepiece
 
 
3
  git+https://github.com/huggingface/transformers
4
  torchaudio==2.0.2
5
  sentencepiece
6
+ python-dotenv