Spaces:
Running
Running
File size: 1,483 Bytes
578ad69 c67898b 578ad69 |
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 |
import gradio as gr
import pandas as pd
import os
import gradio as gr
from pathlib import Path
from huggingface_hub import login
from mutagen.mp3 import MP3
from mutagen.wave import WAVE
import json
from text_explanations import *
from utils import *
persistent_storage = Path('/data')
password_files = os.getenv("password_files")
def get_audio_duration(file_path):
if file_path.lower().endswith('.mp3'):
audio = MP3(file_path)
elif file_path.lower().endswith(('.wav', '.wave')):
audio = WAVE(file_path)
else:
raise ValueError("Unsupported file format")
return audio.info.length # Duration in seconds
def get_storage(password):
# Check if the password is correct
if password == password_files:
# Get the list of file paths and calculate the total usage
files = [
file for file in persistent_storage.glob("**/*.csv") if file.is_file()
]
# Calculate total usage (in bytes)
usage = sum([file.stat().st_size for file in files])
# Convert file paths to strings for Gradio's File component
file_paths = [str(file.resolve()) for file in files]
# Return the file paths (as strings) and the total usage in GB
return file_paths, f"{usage / (1024.0 ** 3):.3f}GB"
else:
return gr.Warning("Please provide the correct password"), None
def count_clicks(n_clicks):
n_clicks = n_clicks + 1
return n_clicks |