juancopi81 commited on
Commit
6b76298
1 Parent(s): c1363ca

Add score as image

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -8,6 +8,7 @@ import gradio as gr
8
  import note_seq
9
  from pytube import YouTube
10
  from pydub import AudioSegment
 
11
 
12
  from inferencemodel import InferenceModel
13
  from utils import upload_audio, create_image_from_note_sequence
@@ -72,11 +73,15 @@ def inference(yt_audio_path):
72
  int16_data = note_seq.audio_io.float_samples_to_int16(array_of_floats)
73
  piano_roll = create_image_from_note_sequence(est_ns)
74
 
75
- return "./transcribed.mid", (SAMPLE_RATE, int16_data), piano_roll
 
 
 
76
 
77
  title = "Transcribe music from YouTube videos using Transformers."
78
  description = """
79
  Gradio demo for Music Transcription with Transformers. Read more in the links below.
 
80
  """
81
  article = "<p style='text-align: center'><a href='https://magenta.tensorflow.org/transcription-with-transformers' target='_blank'>Blog: Music Transcription with Transformers</a> | <a href='https://github.com/magenta/mt3' target='_blank'>Github Repo</a></p>"
82
 
@@ -120,10 +125,11 @@ with demo:
120
  midi_audio = gr.Audio()
121
  with gr.Row():
122
  piano_roll = gr.Image()
 
123
 
124
  btn.click(inference,
125
  inputs=yt_audio_path,
126
- outputs=[midi_file, midi_audio, piano_roll])
127
 
128
  gr.Markdown(article)
129
 
 
8
  import note_seq
9
  from pytube import YouTube
10
  from pydub import AudioSegment
11
+ from music21 import converter
12
 
13
  from inferencemodel import InferenceModel
14
  from utils import upload_audio, create_image_from_note_sequence
 
73
  int16_data = note_seq.audio_io.float_samples_to_int16(array_of_floats)
74
  piano_roll = create_image_from_note_sequence(est_ns)
75
 
76
+ parsed = converter.parse("./transcribed.mid")
77
+ parsed.write("./transcribed.png")
78
+
79
+ return "./transcribed.mid", (SAMPLE_RATE, int16_data), piano_roll, "./transcribed.png"
80
 
81
  title = "Transcribe music from YouTube videos using Transformers."
82
  description = """
83
  Gradio demo for Music Transcription with Transformers. Read more in the links below.
84
+ To use this demo, just add a YouTube link with the music you want to transcribe.
85
  """
86
  article = "<p style='text-align: center'><a href='https://magenta.tensorflow.org/transcription-with-transformers' target='_blank'>Blog: Music Transcription with Transformers</a> | <a href='https://github.com/magenta/mt3' target='_blank'>Github Repo</a></p>"
87
 
 
125
  midi_audio = gr.Audio()
126
  with gr.Row():
127
  piano_roll = gr.Image()
128
+ score = gr.Image()
129
 
130
  btn.click(inference,
131
  inputs=yt_audio_path,
132
+ outputs=[midi_file, midi_audio, piano_roll, score])
133
 
134
  gr.Markdown(article)
135