Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import matchering as mg | |
| import tempfile | |
| import os | |
| from pyharp import ModelCard, build_endpoint | |
| model_card = ModelCard( | |
| name="Matchering 2.0", | |
| description="Automatic audio mastering using a reference track.", | |
| author="Matchering", | |
| tags=["mastering", "audio", "production"] | |
| ) | |
| def process_fn(target_path, reference_path): | |
| try: | |
| output_file = tempfile.NamedTemporaryFile( | |
| delete=False, suffix=".wav" | |
| ).name | |
| mg.process( | |
| target=target_path, | |
| reference=reference_path, | |
| results=[mg.pcm16(output_file)], | |
| ) | |
| return output_file | |
| except Exception as e: | |
| print("Error:", e) | |
| return target_path | |
| with gr.Blocks() as demo: | |
| input_target = gr.Audio(type="filepath", label="Target Track").harp_required(True) | |
| input_reference = gr.Audio(type="filepath", label="Reference Track").harp_required(True) | |
| output_audio = gr.Audio(type="filepath", label="Mastered Output") | |
| build_endpoint( | |
| model_card=model_card, | |
| process_fn=process_fn, | |
| input_components=[input_target, input_reference], | |
| output_components=[output_audio], | |
| ) | |
| if __name__ == "__main__": | |
| demo.queue().launch( | |
| server_name="0.0.0.0", | |
| server_port=7860 | |
| ) | |