Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,13 +116,11 @@ QUESTION_SET = [
|
|
116 |
def load_or_initialize_count_json(audio_paths):
|
117 |
# Add filelock to /workspace/count.json
|
118 |
lock_path = COUNT_JSON_PATH + ".lock"
|
119 |
-
|
120 |
try:
|
121 |
api = HfApi()
|
122 |
repo_id = "intersteller2887/Turing-test-dataset"
|
123 |
hf_token = os.getenv("HF_TOKEN")
|
124 |
count_json = None
|
125 |
-
|
126 |
try:
|
127 |
count_json = api.get_file(
|
128 |
path_in_repo=COUNT_JSON_REPO_PATH,
|
@@ -130,16 +128,17 @@ def load_or_initialize_count_json(audio_paths):
|
|
130 |
repo_type="dataset",
|
131 |
token=hf_token
|
132 |
)
|
133 |
-
|
|
|
134 |
except Exception as e:
|
135 |
-
print(f"
|
136 |
-
|
137 |
# Read of count.json will wait for 10 seconds until another thread involving releases it, and then add a lock to it
|
138 |
with FileLock(lock_path, timeout=10):
|
139 |
# If count.json exists: load into count_data
|
|
|
140 |
with open(COUNT_JSON_PATH, "wb") as f:
|
141 |
f.write(count_json)
|
142 |
-
# Else initialize count_data with orderedDict
|
143 |
if os.path.exists(COUNT_JSON_PATH):
|
144 |
with open(COUNT_JSON_PATH, "r", encoding="utf-8") as f:
|
145 |
count_data = json.load(f, object_pairs_hook=collections.OrderedDict)
|
|
|
116 |
def load_or_initialize_count_json(audio_paths):
|
117 |
# Add filelock to /workspace/count.json
|
118 |
lock_path = COUNT_JSON_PATH + ".lock"
|
|
|
119 |
try:
|
120 |
api = HfApi()
|
121 |
repo_id = "intersteller2887/Turing-test-dataset"
|
122 |
hf_token = os.getenv("HF_TOKEN")
|
123 |
count_json = None
|
|
|
124 |
try:
|
125 |
count_json = api.get_file(
|
126 |
path_in_repo=COUNT_JSON_REPO_PATH,
|
|
|
128 |
repo_type="dataset",
|
129 |
token=hf_token
|
130 |
)
|
131 |
+
except Exception as e:
|
132 |
+
print(f"Count not download count.json from dataset {e}")
|
133 |
except Exception as e:
|
134 |
+
print(f"Count not download count.json from dataset {e}")
|
135 |
+
|
136 |
# Read of count.json will wait for 10 seconds until another thread involving releases it, and then add a lock to it
|
137 |
with FileLock(lock_path, timeout=10):
|
138 |
# If count.json exists: load into count_data
|
139 |
+
# Else initialize count_data with orderedDict
|
140 |
with open(COUNT_JSON_PATH, "wb") as f:
|
141 |
f.write(count_json)
|
|
|
142 |
if os.path.exists(COUNT_JSON_PATH):
|
143 |
with open(COUNT_JSON_PATH, "r", encoding="utf-8") as f:
|
144 |
count_data = json.load(f, object_pairs_hook=collections.OrderedDict)
|