Commit
·
c99f4df
1
Parent(s):
3978e51
Update helpers.py
Browse files- helpers.py +1 -18
helpers.py
CHANGED
@@ -5,7 +5,7 @@ import re
|
|
5 |
import subprocess
|
6 |
import random
|
7 |
import yaml
|
8 |
-
from pathlib import Path
|
9 |
import torch
|
10 |
import gradio as gr
|
11 |
import threading
|
@@ -20,9 +20,6 @@ from datetime import datetime
|
|
20 |
import yt_dlp
|
21 |
import validators
|
22 |
from pytube import YouTube
|
23 |
-
from google.colab import auth
|
24 |
-
from googleapiclient.discovery import build
|
25 |
-
from googleapiclient.http import MediaIoBaseDownload
|
26 |
import io
|
27 |
import math
|
28 |
import hashlib
|
@@ -30,7 +27,6 @@ import gc
|
|
30 |
import psutil
|
31 |
import concurrent.futures
|
32 |
from tqdm import tqdm
|
33 |
-
from google.oauth2.credentials import Credentials
|
34 |
import tempfile
|
35 |
from urllib.parse import urlparse, quote
|
36 |
import gdown
|
@@ -65,25 +61,17 @@ def tuple_constructor(loader, node):
|
|
65 |
values = loader.construct_sequence(node)
|
66 |
return tuple(values)
|
67 |
|
68 |
-
# PyYAML ile tuple constructor'ı kaydet
|
69 |
yaml.SafeLoader.add_constructor('tag:yaml.org,2002:python/tuple', tuple_constructor)
|
70 |
|
71 |
def update_model_dropdown(category):
|
72 |
"""Kategoriye göre model dropdown'ını günceller."""
|
73 |
return gr.Dropdown(choices=list(MODEL_CONFIGS[category].keys()), label="Model")
|
74 |
|
75 |
-
# Dosya yükleme işlevi (güncellenmiş)
|
76 |
def handle_file_upload(uploaded_file, file_path, is_auto_ensemble=False):
|
77 |
-
clear_temp_folder("/tmp", exclude_items=["gradio", "config.json"])
|
78 |
-
clear_directory(INPUT_DIR)
|
79 |
-
os.makedirs(INPUT_DIR, exist_ok=True)
|
80 |
-
clear_directory(INPUT_DIR)
|
81 |
if uploaded_file:
|
82 |
-
# Yüklenen dosyayı INPUT_DIR'a kaydet
|
83 |
target_path = save_uploaded_file(uploaded_file, is_input=True)
|
84 |
return target_path, target_path
|
85 |
elif file_path and os.path.exists(file_path):
|
86 |
-
# Mevcut dosyayı INPUT_DIR'a kopyala
|
87 |
target_path = os.path.join(INPUT_DIR, os.path.basename(file_path))
|
88 |
shutil.copy(file_path, target_path)
|
89 |
return target_path, target_path
|
@@ -169,14 +157,9 @@ def generate_random_port():
|
|
169 |
return random.randint(1000, 9000)
|
170 |
|
171 |
def update_file_list():
|
172 |
-
# OUTPUT_DIR ve OLD_OUTPUT_DIR'dan .wav dosyalarını al
|
173 |
output_files = glob.glob(os.path.join(OUTPUT_DIR, "*.wav"))
|
174 |
old_output_files = glob.glob(os.path.join(OLD_OUTPUT_DIR, "*.wav"))
|
175 |
-
|
176 |
-
# Dosya listesini birleştir
|
177 |
files = output_files + old_output_files
|
178 |
-
|
179 |
-
# Gradio Dropdown için seçenekleri döndür
|
180 |
return gr.Dropdown(choices=files)
|
181 |
|
182 |
def save_uploaded_file(uploaded_file, is_input=False, target_dir=None):
|
|
|
5 |
import subprocess
|
6 |
import random
|
7 |
import yaml
|
8 |
+
from pathlib import Path
|
9 |
import torch
|
10 |
import gradio as gr
|
11 |
import threading
|
|
|
20 |
import yt_dlp
|
21 |
import validators
|
22 |
from pytube import YouTube
|
|
|
|
|
|
|
23 |
import io
|
24 |
import math
|
25 |
import hashlib
|
|
|
27 |
import psutil
|
28 |
import concurrent.futures
|
29 |
from tqdm import tqdm
|
|
|
30 |
import tempfile
|
31 |
from urllib.parse import urlparse, quote
|
32 |
import gdown
|
|
|
61 |
values = loader.construct_sequence(node)
|
62 |
return tuple(values)
|
63 |
|
|
|
64 |
yaml.SafeLoader.add_constructor('tag:yaml.org,2002:python/tuple', tuple_constructor)
|
65 |
|
66 |
def update_model_dropdown(category):
|
67 |
"""Kategoriye göre model dropdown'ını günceller."""
|
68 |
return gr.Dropdown(choices=list(MODEL_CONFIGS[category].keys()), label="Model")
|
69 |
|
|
|
70 |
def handle_file_upload(uploaded_file, file_path, is_auto_ensemble=False):
|
|
|
|
|
|
|
|
|
71 |
if uploaded_file:
|
|
|
72 |
target_path = save_uploaded_file(uploaded_file, is_input=True)
|
73 |
return target_path, target_path
|
74 |
elif file_path and os.path.exists(file_path):
|
|
|
75 |
target_path = os.path.join(INPUT_DIR, os.path.basename(file_path))
|
76 |
shutil.copy(file_path, target_path)
|
77 |
return target_path, target_path
|
|
|
157 |
return random.randint(1000, 9000)
|
158 |
|
159 |
def update_file_list():
|
|
|
160 |
output_files = glob.glob(os.path.join(OUTPUT_DIR, "*.wav"))
|
161 |
old_output_files = glob.glob(os.path.join(OLD_OUTPUT_DIR, "*.wav"))
|
|
|
|
|
162 |
files = output_files + old_output_files
|
|
|
|
|
163 |
return gr.Dropdown(choices=files)
|
164 |
|
165 |
def save_uploaded_file(uploaded_file, is_input=False, target_dir=None):
|