GVAmaresh
commited on
Commit
·
3ae44f3
1
Parent(s):
5f33887
dev: check working
Browse files
app.py
CHANGED
@@ -30,20 +30,26 @@ def reencode_audio(input_path, output_path):
|
|
30 |
]
|
31 |
subprocess.run(command, check=True)
|
32 |
|
33 |
-
def download_and_read_h5(file_id):
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
gdown.download(url, output_path, quiet=False)
|
38 |
-
|
39 |
-
with h5py.File(output_path, 'r') as h5_file:
|
40 |
-
print("Keys:", list(h5_file.keys()))
|
41 |
-
dataset_name = list(h5_file.keys())[0]
|
42 |
-
data = h5_file[dataset_name][:]
|
43 |
-
print(data)
|
44 |
|
45 |
file_id_1 = '1zhisRgRi2qBFX73VFhzh-Ho93MORQqVa'
|
46 |
-
download_and_read_h5(file_id_1)
|
47 |
|
48 |
file_id_2 = '1wIaycDFGTF3e0PpAHKk-GLnxk4cMehOU'
|
49 |
-
download_and_read_h5(file_id_2)
|
|
|
30 |
]
|
31 |
subprocess.run(command, check=True)
|
32 |
|
33 |
+
def download_and_read_h5(file_id, dataset_name):
|
34 |
+
file_path = f"/tmp/{file_id}.h5"
|
35 |
+
# dataset_name = "your_dataset_name"
|
36 |
+
|
37 |
+
with h5py.File(file_path, "r") as h5_file:
|
38 |
+
if dataset_name in h5_file:
|
39 |
+
obj = h5_file[dataset_name]
|
40 |
+
if isinstance(obj, h5py.Dataset):
|
41 |
+
data = obj[:]
|
42 |
+
print("Data loaded successfully")
|
43 |
+
return data
|
44 |
+
else:
|
45 |
+
print(f"'{dataset_name}' is a group. Inspect its contents.")
|
46 |
+
print(list(obj.keys()))
|
47 |
+
else:
|
48 |
+
print(f"Dataset '{dataset_name}' not found in the file.")
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
file_id_1 = '1zhisRgRi2qBFX73VFhzh-Ho93MORQqVa'
|
52 |
+
download_and_read_h5(file_id_1, "check_1")
|
53 |
|
54 |
file_id_2 = '1wIaycDFGTF3e0PpAHKk-GLnxk4cMehOU'
|
55 |
+
download_and_read_h5(file_id_2, "check_2")
|