Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests, zipfile, os, shutil | |
| KAGGLE_API_URL = "https://seminarial-blunderingly-sylvie.ngrok-free.dev/separate" | |
| def process_via_kaggle(audio_path, model_choice): | |
| if audio_path is None: return None, None, "သီချင်းတင်ပေးပါ။" | |
| try: | |
| if os.path.exists("extracted"): shutil.rmtree("extracted") | |
| with open(audio_path, 'rb') as f: | |
| response = requests.post(KAGGLE_API_URL, files={'audio': f}, data={'model': model_choice}, timeout=600) | |
| if response.status_code == 200: | |
| with open("results.zip", "wb") as f: f.write(response.content) | |
| with zipfile.ZipFile("results.zip", 'r') as zip_ref: zip_ref.extractall("extracted") | |
| vocal_file, inst_file = None, None | |
| for file in os.listdir("extracted"): | |
| path = os.path.join("extracted", file) | |
| # ဖိုင်အမည်များကို စစ်ဆေးခြင်း | |
| if "Vocals" in file: vocal_file = path | |
| elif any(x in file for x in ["Instrumental", "No Vocals", "No Drum-Bass"]): inst_file = path | |
| return inst_file, vocal_file, "အောင်မြင်စွာ ခွဲထုတ်ပြီးပါပြီ။" | |
| else: | |
| return None, None, f"Error: {response.text}" | |
| except Exception as e: | |
| return None, None, str(e) | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# 🎵 MIKEKEL Ultimate AI Karaoke") | |
| with gr.Row(): | |
| audio_in = gr.Audio(label="သီချင်းတင်ပါ", type="filepath") | |
| model_in = gr.Dropdown( | |
| choices=["MelRoformer_deux", "BS_Roformer_HyperACE", "BS_Roformer_v2"], | |
| value="MelRoformer_deux", label="AI Model ရွေးချယ်ပါ" | |
| ) | |
| btn = gr.Button("စတင်ခွဲထုတ်မည်", variant="primary") | |
| with gr.Row(): | |
| inst_out = gr.Audio(label="Instrumental (တီးလုံး)") | |
| vocal_out = gr.Audio(label="Vocals (အဆိုသံ)") | |
| status = gr.Textbox(label="Status") | |
| btn.click(process_via_kaggle, [audio_in, model_in], [inst_out, vocal_out, status]) | |
| demo.launch() | |