File size: 1,826 Bytes
cca0e04
 
 
 
 
 
453cd84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4996177
 
 
 
 
 
 
 
 
dc2f8e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def greet_json():
    return {"Hello": "World!"}

#-----------------------------------------------------------------------------------------

import os

os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
os.environ["FONTCONFIG_PATH"] = "/tmp/fontconfig"
os.environ["HF_HOME"] = "/tmp/huggingface_cache"

os.makedirs("/tmp/matplotlib", exist_ok=True)
os.makedirs("/tmp/fontconfig", exist_ok=True)
os.makedirs("/tmp/huggingface_cache", exist_ok=True)

from torchaudio.pipelines import WAV2VEC2_BASE
bundle = WAV2VEC2_BASE
model = bundle.get_model()
print("Model downloaded successfully!")

#-----------------------------------------------------------------------------------------
import subprocess

def reencode_audio(input_path, output_path):
    command = [
        'ffmpeg', '-i', input_path, '-acodec', 'pcm_s16le', '-ar', '16000', '-ac', '1', output_path
    ]
    subprocess.run(command, check=True)

#-----------------------------------------------------------------------------------------

import gdown
import h5py
import io

file_id = '1zhisRgRi2qBFX73VFhzh-Ho93MORQqVa'
url = f"https://drive.google.com/uc?id={file_id}"

response = gdown.download(url, None, quiet=False)

with h5py.File(io.BytesIO(response.content), 'r') as h5_file:
    print("Keys:", list(h5_file.keys()))
    dataset_name = list(h5_file.keys())[0]
    data = h5_file[dataset_name][:]
    print(data)

file_id = '1wIaycDFGTF3e0PpAHKk-GLnxk4cMehOU'
url = f"https://drive.google.com/uc?id={file_id}"

response2 = gdown.download(url, None, quiet=False)

with h5py.File(io.BytesIO(response2.content), 'r') as h5_file:
    print("Keys:", list(h5_file.keys()))
    dataset_name = list(h5_file.keys())[0]
    data = h5_file[dataset_name][:]
    print(data)