youngtsai commited on
Commit
7f75261
·
1 Parent(s): d4257d0

if is_env_local:

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -1,9 +1,19 @@
1
  import gradio as gr
2
  import requests
3
  import os
 
4
 
5
- PASSWORD = os.getenv("PASSWORD")
6
- ELSA_API_TOKEN = os.getenv("ELSA_API_TOKEN")
 
 
 
 
 
 
 
 
 
7
 
8
  def verify_password(password):
9
  if password == PASSWORD:
@@ -27,7 +37,7 @@ def score_audio_plus(password, audio, api_plan, return_json):
27
  # Prepare files and data for POST request
28
  with open(audio, "rb") as audio_file:
29
  files = {
30
- 'audio_file': ("audio", audio_file, 'audio/wav')
31
  }
32
 
33
  data = {
 
1
  import gradio as gr
2
  import requests
3
  import os
4
+ import json
5
 
6
+ is_env_local = os.getenv("IS_ENV_LOCAL", "false") == "true"
7
+ print(f"is_env_local: {is_env_local}")
8
+
9
+ if is_env_local:
10
+ with open("local_config.json") as f:
11
+ config = json.load(f)
12
+ PASSWORD = config["PASSWORD"]
13
+ ELSA_API_TOKEN = config["ELSA_API_TOKEN"]
14
+ else:
15
+ PASSWORD = os.getenv("PASSWORD")
16
+ ELSA_API_TOKEN = os.getenv("ELSA_API_TOKEN")
17
 
18
  def verify_password(password):
19
  if password == PASSWORD:
 
37
  # Prepare files and data for POST request
38
  with open(audio, "rb") as audio_file:
39
  files = {
40
+ 'audio_file': audio_file
41
  }
42
 
43
  data = {