| | import gradio as gr |
| | from gradio_client import Client, handle_file |
| | from transformers import pipeline |
| |
|
| | |
| | classifier = pipeline("audio-classification", model="MIT/ast-finetuned-audioset") |
| | mastering_client = Client("amaai-lab/SonicMaster") |
| |
|
| | def master_process(audio_path): |
| | if audio_path is None: return None, None, "Upload audio first." |
| | |
| | |
| | results = classifier(audio_path) |
| | top_genre = results[0]['label'] |
| | |
| | |
| | result = mastering_client.predict( |
| | audio=handle_file(audio_path), |
| | prompt=f"Professional {top_genre} master.", |
| | api_name="/predict" |
| | ) |
| | mastered_path = result[1] |
| | |
| | |
| | return mastered_path, mastered_path, f"Mode: Mastered ({top_genre})", mastered_path |
| |
|
| | def toggle_audio(choice, raw_path, mastered_path): |
| | |
| | if choice == "Mastered β¨": |
| | return mastered_path |
| | return raw_path |
| |
|
| | with gr.Blocks(theme=gr.themes.Soft()) as demo: |
| | gr.Markdown("# ποΈ Pro Mastering Suite with A/B Bypass") |
| | |
| | |
| | raw_storage = gr.State() |
| | mastered_storage = gr.State() |
| | |
| | with gr.Row(): |
| | with gr.Column(): |
| | in_audio = gr.Audio(label="1. Upload Raw Demo", type="filepath") |
| | run_btn = gr.Button("π MASTER AUDIO", variant="primary") |
| | |
| | with gr.Column(): |
| | |
| | monitor_player = gr.Audio(label="2. Monitor Output", interactive=False) |
| | |
| | |
| | mode_toggle = gr.Radio( |
| | choices=["Original π", "Mastered β¨"], |
| | label="Bypass Toggle (A/B Test)", |
| | value="Mastered β¨", |
| | interactive=True |
| | ) |
| | |
| | download_link = gr.File(label="3. Export Final WAV") |
| |
|
| | |
| | run_btn.click( |
| | fn=master_process, |
| | inputs=in_audio, |
| | outputs=[monitor_player, download_link, monitor_player.label, mastered_storage] |
| | ).then(lambda x: x, inputs=in_audio, outputs=raw_storage) |
| |
|
| | |
| | mode_toggle.change( |
| | fn=toggle_audio, |
| | inputs=[mode_toggle, raw_storage, mastered_storage], |
| | outputs=monitor_player |
| | ) |
| |
|
| | demo.launch() |