(self, primer_melody, backing_chords, temperature=1.0,
                      beam_size=1, branch_factor=1, steps_per_iteration=1)
return melody
Generate a melody from a primer melody and backing chords.

    Args:
      primer_melody: The primer melody, a Melody object. Should be the same
          length as the primer chords.
      backing_chords: The backing chords, a ChordProgression object. Must be at
          least as long as the primer melody. The melody will be extended to
          match the length of the backing chords.
      temperature: A float specifying how much to divide the logits by
          before computing the softmax. Greater than 1.0 makes melodies more
          random, less than 1.0 makes melodies less random.
      beam_size: An integer, beam size to use when generating melodies via beam
          search.
      branch_factor: An integer, beam search branch factor to use.
      steps_per_iteration: An integer, number of melody steps to take per beam
          search iteration.

    Returns:
      The generated Melody object (which begins with the provided primer
          melody).
Generate a melody from a primer melody and backing chords.
Generate a melody from a primer melody and backing chords .
def generate_melody(self, primer_melody, backing_chords, temperature=1.0,
                      beam_size=1, branch_factor=1, steps_per_iteration=1):
    """Generate a melody from a primer melody and backing chords.

    Args:
      primer_melody: The primer melody, a Melody object. Should be the same
          length as the primer chords.
      backing_chords: The backing chords, a ChordProgression object. Must be at
          least as long as the primer melody. The melody will be extended to
          match the length of the backing chords.
      temperature: A float specifying how much to divide the logits by
          before computing the softmax. Greater than 1.0 makes melodies more
          random, less than 1.0 makes melodies less random.
      beam_size: An integer, beam size to use when generating melodies via beam
          search.
      branch_factor: An integer, beam search branch factor to use.
      steps_per_iteration: An integer, number of melody steps to take per beam
          search iteration.

    Returns:
      The generated Melody object (which begins with the provided primer
          melody).
    """
    melody = copy.deepcopy(primer_melody)
    chords = copy.deepcopy(backing_chords)

    transpose_amount = melody.squash(
        self._config.min_note,
        self._config.max_note,
        self._config.transpose_to_key)
    chords.transpose(transpose_amount)

    num_steps = len(chords)
    melody = self._generate_events(num_steps, melody, temperature, beam_size,
                                   branch_factor, steps_per_iteration,
                                   control_events=chords)

    melody.transpose(-transpose_amount)

    return melody
def generate_melody ( self , primer_melody , backing_chords , temperature = 1.0 , beam_size = 1 , branch_factor = 1 , steps_per_iteration = 1 ) : melody = copy . deepcopy ( primer_melody ) chords = copy . deepcopy ( backing_chords ) transpose_amount = melody . squash ( self . _config . min_note , self . _config . max_note , self . _config . transpose_to_key ) chords . transpose ( transpose_amount ) num_steps = len ( chords ) melody = self . _generate_events ( num_steps , melody , temperature , beam_size , branch_factor , steps_per_iteration , control_events = chords ) melody . transpose ( - transpose_amount ) return melody