(self, ns)
return ids
Transform a NoteSequence into a list of performance event indices.

    Args:
      ns: NoteSequence proto containing the performance to encode.

    Returns:
      ids: List of performance event indices.
Transform a NoteSequence into a list of performance event indices.
Transform a NoteSequence into a list of performance event indices .
def encode_note_sequence(self, ns):
    """Transform a NoteSequence into a list of performance event indices.

    Args:
      ns: NoteSequence proto containing the performance to encode.

    Returns:
      ids: List of performance event indices.
    """
    performance = note_seq.Performance(
        note_seq.quantize_note_sequence_absolute(ns, self._steps_per_second),
        num_velocity_bins=self._num_velocity_bins)

    event_ids = [self._encoding.encode_event(event) + self.num_reserved_ids
                 for event in performance]

    # Greedily encode performance event n-grams as new indices.
    ids = []
    j = 0
    while j < len(event_ids):
      ngram = ()
      for i in range(j, len(event_ids)):
        ngram += (event_ids[i],)
        if self._ngrams_trie.has_key(ngram):
          best_ngram = ngram
        if not self._ngrams_trie.has_subtrie(ngram):
          break
      ids.append(self._ngrams_trie[best_ngram])
      j += len(best_ngram)

    if self._add_eos:
      ids.append(text_encoder.EOS_ID)

    return ids
def encode_note_sequence ( self , ns ) : performance = note_seq . Performance ( note_seq . quantize_note_sequence_absolute ( ns , self . _steps_per_second ) , num_velocity_bins = self . _num_velocity_bins ) event_ids = [ self . _encoding . encode_event ( event ) + self . num_reserved_ids for event in performance ] # Greedily encode performance event n-grams as new indices. ids = [ ] j = 0 while j < len ( event_ids ) : ngram = ( ) for i in range ( j , len ( event_ids ) ) : ngram += ( event_ids [ i ] , ) if self . _ngrams_trie . has_key ( ngram ) : best_ngram = ngram if not self . _ngrams_trie . has_subtrie ( ngram ) : break ids . append ( self . _ngrams_trie [ best_ngram ] ) j += len ( best_ngram ) if self . _add_eos : ids . append ( text_encoder . EOS_ID ) return ids