PierreHanna commited on
Commit
10d8431
Β·
1 Parent(s): 7bfd63b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -22
app.py CHANGED
@@ -19,45 +19,25 @@ print("DEBUG ", encoder_text_path)
19
  os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
20
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
21
 
22
-
23
  python_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename="models.py",
24
  use_auth_token=os.environ['TOKEN'])
25
-
26
  print(python_path)
27
  os.system('ls -la')
28
- #from models import *
29
-
30
  sys.path.append(os.environ['PRIVATE_DIR'])
31
  from models import *
32
-
33
  preprocess_model, model = get_models()
34
-
35
  index_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['INDEX'],
36
  use_auth_token=os.environ['TOKEN'])
37
  indexnames_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['INDEX_NAMES'],
38
  use_auth_token=os.environ['TOKEN'])
39
  catalog_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['CATALOG'],
40
  use_auth_token=os.environ['TOKEN'])
41
-
42
- #url
43
- url_dict={}
44
- with open(catalog_path) as csv_file:
45
- csv_reader = csv.reader(csv_file, delimiter=';')
46
- for row in csv_reader:
47
- f = row[2].split('/')[-1]
48
- url_dict[f.split('/')[-1][:-4]] = row[2]
49
-
50
- # names index
51
  audio_names = joblib.load(open(indexnames_path, 'rb'))
52
-
53
- # load embed audio catalog
54
  index = faiss.read_index(index_path)
55
-
56
  encoder_text = tf.keras.models.load_model(encoder_text_path)
57
 
58
-
59
  def process(prompt, lang):
60
-
61
  now = datetime.datetime.now()
62
  print()
63
  print('*************')
@@ -110,7 +90,6 @@ poc_examples = [#[["I love learning machine learning"],["autre"]]
110
  ["90 eurodance beat","en"],
111
  ]
112
 
113
-
114
  outputs = [gr.Audio(label="Track 1"), gr.Audio(label="Track 2"), gr.Audio(label="Track 3"), gr.Audio(label="Track 4"), gr.Audio(label="Track 5")]
115
  demo1 = gr.Interface(fn=process, inputs=inputs, outputs=outputs, examples=poc_examples, cache_examples=False)
116
 
 
19
  os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
20
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
21
 
 
22
  python_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename="models.py",
23
  use_auth_token=os.environ['TOKEN'])
 
24
  print(python_path)
25
  os.system('ls -la')
 
 
26
  sys.path.append(os.environ['PRIVATE_DIR'])
27
  from models import *
 
28
  preprocess_model, model = get_models()
 
29
  index_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['INDEX'],
30
  use_auth_token=os.environ['TOKEN'])
31
  indexnames_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['INDEX_NAMES'],
32
  use_auth_token=os.environ['TOKEN'])
33
  catalog_path = hf_hub_download(repo_id="PierreHanna/TextRetrieval", repo_type="space", filename=os.environ['CATALOG'],
34
  use_auth_token=os.environ['TOKEN'])
35
+ url_dict=get_durl(catalog_path)
 
 
 
 
 
 
 
 
 
36
  audio_names = joblib.load(open(indexnames_path, 'rb'))
 
 
37
  index = faiss.read_index(index_path)
 
38
  encoder_text = tf.keras.models.load_model(encoder_text_path)
39
 
 
40
  def process(prompt, lang):
 
41
  now = datetime.datetime.now()
42
  print()
43
  print('*************')
 
90
  ["90 eurodance beat","en"],
91
  ]
92
 
 
93
  outputs = [gr.Audio(label="Track 1"), gr.Audio(label="Track 2"), gr.Audio(label="Track 3"), gr.Audio(label="Track 4"), gr.Audio(label="Track 5")]
94
  demo1 = gr.Interface(fn=process, inputs=inputs, outputs=outputs, examples=poc_examples, cache_examples=False)
95