GVAmaresh
dev: check working
dc2f8e3
raw
history blame
1.83 kB
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)