saysynth.cli.commands.midi

Synthesize a melody from a monophonic midi file.

 1"""
 2Synthesize a melody from a monophonic midi file.
 3"""
 4
 5import os
 6
 7import click
 8
 9from saysynth.cli.options import (adsr_opts, group_options, log_configurations,
10                                  phoneme_opts, randomize_velocity_opt,
11                                  say_opts, segment_opts, start_opts, text_opt,
12                                  velocity_emphasis_opt, volume_level_opts,
13                                  volume_range_opt)
14from saysynth.constants import DEFAULT_SEQUENCE_NAME
15from saysynth.core import MidiTrack, controller
16
17
18def run(**kwargs):
19    midi_track = MidiTrack(**kwargs)
20    midi_track.cli(**kwargs)
21
22
23@click.command()
24@click.argument("midi_file", required=True)
25@click.option(
26    "-l",
27    "--loops",
28    default=1,
29    show_default=True,
30    type=int,
31    help="The number of times to loop the midi file",
32)
33@start_opts
34@phoneme_opts
35@text_opt
36@group_options(velocity_emphasis_opt, volume_range_opt, randomize_velocity_opt)
37@volume_level_opts
38@adsr_opts
39@segment_opts
40@click.option(
41    "-o",
42    "--output-file",
43    type=str,
44    help="A filepath to write the generated text to",
45)
46@say_opts
47def cli(**kwargs):
48    """
49    Synthesize a melody from a fully-monophonic midi file.
50    """
51    if kwargs["yaml"]:
52        return log_configurations("midi", **kwargs)
53    parent_pid = os.getpid()
54    ad = kwargs.get("audio_device", "")
55    controller.add_parent_pid(DEFAULT_SEQUENCE_NAME, "midi", ad, parent_pid)
56    kwargs["parent_pid"] = parent_pid
57    return run(**kwargs)
def run(**kwargs):
19def run(**kwargs):
20    midi_track = MidiTrack(**kwargs)
21    midi_track.cli(**kwargs)
cli = <Command cli>

Synthesize a melody from a fully-monophonic midi file.