Berker Banar
test
b156577
import gradio as gr
from gradio.components import Markdown as md
from generate_whole import synthesize_audio
import os
def predict(image):
# synthesize_audio()
path = os.path.join(os.path.dirname(__file__), "Whole/Designed_Audio/ex1/ex1.wav")
return path
# inputs = gr.Interface(lambda x: x, gr.Image(source='canvas', tool='color-sketch'), gr.Image())
# outputs = gr.Audio(label="Composed Music")
# gr.Interface(fn=predict,
# inputs=inputs,
# outputs=outputs,
# live=True).launch()
# gr.Interface(lambda x: x, gr.Image(source='canvas', tool='color-sketch'), gr.Image())
demo = gr.Blocks()
# img_dir = os.path.join(os.path.dirname(__file__), "example_images")
# examples = ['1_graphic_score_excerpt.png','Graphic_Score_Excerpts.png']
# gr.Gallery(value=lambda: [os.path.join(img_dir, img) for img in os.listdir(img_dir)])
drawing_board = gr.Image(source="canvas", tool="color-sketch", shape = (406,249))
drawing_board.style(height = 406, width = 249)
audio_output = gr.Audio(os.path.join(os.path.dirname(__file__), "Whole/Designed_Audio/ex1/ex1.wav"), label="Composed Music")
io4a = gr.Interface(
predict,
inputs = [drawing_board],
outputs = [audio_output]
# examples = examples
)
with gr.Blocks() as demo:
gr.Markdown(
"""
<center>
<h1>A Tool for Composing Music via Graphic Scores in the style of György Ligeti's Artikulation using Self-supervised Representation Learning</h1>
</center>
<left>
<h4>Draw a graphic score in the style of the examples below and click on submit to generate your musical composition based on your drawing!</h4>
<h4>Here is the YouTube link to Gyorgy Ligeti's Artikulation following its graphic score which is designed by Rainer Wehinger: <a href="https://www.youtube.com/watch?v=71hNl_skTZQ">https://www.youtube.com/watch?v=71hNl_skTZQ</a></h4>
<h4>Please let us know about your comments via <u>b.banar@qmul.ac.uk</u> and enjoy! This tool is designed by Berker Banar and Simon Colton.</h4>
</left>
<center>
<img src="https://huggingface.co/spaces/bbanar/SSRL_Artikulation/resolve/main/graphic_score_examples.png" alt="Graphic_Score" width = "1727">
</center>
"""
)
with gr.Row():
with gr.Column(scale=1):
drawing_board
with gr.Column(scale=4):
audio_output
io4a.render()
if __name__ == "__main__":
demo.launch()