synthviz
synthviz is a library for creating visualizations of piano-playing from MIDI files. The videos look like this:
Right now, synthviz just provides a Python API. Command-line API is hopefully coming soon!
Requirements
system requirements
You'll need to install a couple of tools that make rendering this video possible:
- ffmpeg (creates video from audio and image video frames) - on Ubuntu,
sudo apt-get install ffmpeg - timidity (synthesizes piano audio from MIDI) - on Ubuntu,
sudo apt-get install timidity
python package requirements
Install this package via pypi:
pip install synthviz
Usage
You can use synthviz through the Python API:
from synthviz import create_video
create_video('river.midi') # provide str path of MIDI file
Options
The create_video function provides a lot of of options:
def create_video(input_midi: str,
video_filename = "output.mp4",
image_width = 1280,
image_height = 720,
black_key_height = 2/3,
falling_note_color = [75, 105, 177], # default: darker blue
pressed_key_color = [197, 208, 231], # default: lighter blue
vertical_speed = 1/4,
fps = 20
)
input_midi(str): path to MIDI filevideo_filename(str): path to output video, synthviz will write the video hereimage_width(int): width of output video in pximage_height(int): height of output video in pxblack_key_height(float): height of black keys as a percentage of piano heightfalling_note_color(Tuple[int]): color of falling keys in video, list of three RGB integerspressed_key_color(Tuple[int]): color of pressed-down keys in video, list of three RGB integersvertical_speed(float): the speed of the falling keys, fraction measured as main-image-heights per secondfps(int): frames-per-second of output video
Creating video from raw audio
With the help of the piano_transcription_inference library, you can make a cool video directly from raw audio!
First, install that library via pip install piano_transcription_inference. Then run the following code:
import librosa
import os
import pathlib
from piano_transcription_inference import PianoTranscription, sample_rate, load_audio
from synthviz import create_video
audio_input = 'my_audio.mp3'
midi_intermediate_filename = 'transcription.mid'
video_filename = 'output.mp4'
transcriptor = PianoTranscription(device='cuda', checkpoint_path='./model.pth')
audio, _ = librosa.core.load(str(audio_input), sr=sample_rate)
transcribed_dict = transcriptor.transcribe(audio, midi_intermediate_filename)
create_video(input_midi=midi_intermediate_filename, video_filename=video_filename)
Credits
The synthviz library was originall adapted from this blog post, "Making Synthesia-style videos in Ubuntu", written by David Barry. Thanks David!
Metadata
Release files for synthviz 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| synthviz-0.0.2.tar.gz | 5.5 kB | Without provenance | Details for synthviz-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| synthviz-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for synthviz-0.0.2-py3-none-any.whl |
Total release size: 11.4 kB
Release files / synthviz-0.0.2.tar.gz
| Download URL | synthviz-0.0.2.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfd7e46621ab1b706aea2d94c8e6abf82cf048df661f898013eab721701927ec
|
|
BLAKE2b-256 checksum How to use checksums |
dce9f7845c0e0aba08579811d02df6ff0e028e7eda9b8d42671d784271034198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / synthviz-0.0.2-py3-none-any.whl
| Download URL | synthviz-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad983814f1efd08be41707883aa23a59aab78baf5d1de3decdf5b8f80e54c788
|
|
BLAKE2b-256 checksum How to use checksums |
7dfc9137d733b3035b9f1a8eb724162d71c4d3b060c856ea41624781cf4c23df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for synthviz 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.