GVAmaresh commited on
Commit
5f33887
·
1 Parent(s): d2010b2

dev: check working

Browse files
Files changed (1) hide show
  1. app.py +17 -32
app.py CHANGED
@@ -1,4 +1,8 @@
1
  from fastapi import FastAPI
 
 
 
 
2
 
3
  app = FastAPI()
4
 
@@ -6,10 +10,6 @@ app = FastAPI()
6
  def greet_json():
7
  return {"Hello": "World!"}
8
 
9
- #-----------------------------------------------------------------------------------------
10
-
11
- import os
12
-
13
  os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
14
  os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
15
  os.environ["FONTCONFIG_PATH"] = "/tmp/fontconfig"
@@ -24,41 +24,26 @@ bundle = WAV2VEC2_BASE
24
  model = bundle.get_model()
25
  print("Model downloaded successfully!")
26
 
27
- #-----------------------------------------------------------------------------------------
28
- import subprocess
29
-
30
  def reencode_audio(input_path, output_path):
31
  command = [
32
  'ffmpeg', '-i', input_path, '-acodec', 'pcm_s16le', '-ar', '16000', '-ac', '1', output_path
33
  ]
34
  subprocess.run(command, check=True)
35
 
36
- #-----------------------------------------------------------------------------------------
37
-
38
- import gdown
39
- import h5py
40
- import io
41
-
42
- file_id = '1zhisRgRi2qBFX73VFhzh-Ho93MORQqVa'
43
- url = f"https://drive.google.com/uc?id={file_id}"
44
-
45
- response = gdown.download(url, None, quiet=False)
46
-
47
- with h5py.File(io.BytesIO(response.content), 'r') as h5_file:
48
- print("Keys:", list(h5_file.keys()))
49
- dataset_name = list(h5_file.keys())[0]
50
- data = h5_file[dataset_name][:]
51
- print(data)
52
 
53
- file_id = '1wIaycDFGTF3e0PpAHKk-GLnxk4cMehOU'
54
- url = f"https://drive.google.com/uc?id={file_id}"
55
 
56
- response2 = gdown.download(url, None, quiet=False)
 
 
 
 
57
 
58
- with h5py.File(io.BytesIO(response2.content), 'r') as h5_file:
59
- print("Keys:", list(h5_file.keys()))
60
- dataset_name = list(h5_file.keys())[0]
61
- data = h5_file[dataset_name][:]
62
- print(data)
63
 
64
- #-----------------------------------------------------------------------------------------
 
 
1
  from fastapi import FastAPI
2
+ import os
3
+ import subprocess
4
+ import gdown
5
+ import h5py
6
 
7
  app = FastAPI()
8
 
 
10
  def greet_json():
11
  return {"Hello": "World!"}
12
 
 
 
 
 
13
  os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
14
  os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
15
  os.environ["FONTCONFIG_PATH"] = "/tmp/fontconfig"
 
24
  model = bundle.get_model()
25
  print("Model downloaded successfully!")
26
 
 
 
 
27
  def reencode_audio(input_path, output_path):
28
  command = [
29
  'ffmpeg', '-i', input_path, '-acodec', 'pcm_s16le', '-ar', '16000', '-ac', '1', output_path
30
  ]
31
  subprocess.run(command, check=True)
32
 
33
+ def download_and_read_h5(file_id):
34
+ url = f"https://drive.google.com/uc?id={file_id}"
35
+ output_path = f"/tmp/{file_id}.h5"
 
 
 
 
 
 
 
 
 
 
 
 
 
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)