{"id":352589,"date":"2024-05-20T22:11:33","date_gmt":"2024-05-20T22:11:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=352589"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=352589","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u043d\u0430\u0443\u0447\u0438\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0442\u0438\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042f \u0443\u0432\u043b\u0435\u043a\u0430\u044e\u0441\u044c \u043c\u0443\u0437\u044b\u043a\u043e\u0439 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0438 \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0432\u0430 \u0445\u043e\u0431\u0431\u0438. \u0423 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0442\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 MIDI. \u042d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0443\u0437\u044b\u043a\u0438. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u0441\u043c\u043e\u0433 \u0441\u043e\u0437\u0434\u0430\u0442\u044c.<\/p>\n<h2>1. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b MIDI-\u0444\u0430\u0439\u043b\u044b \u0441 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0442\u0438\u044f\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/Alex-Kuimov\/generhythm\/tree\/master\/data\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0442\u0443\u0442<\/a>.  \u0412\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043d\u043e\u0442\u0430\u043c\u0438, \u044f \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 &#8212; \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f. <\/p>\n<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2c7\/9c9\/f40\/2c79c9f408aaa3e2fe691c3313197029.png\" width=\"770\" height=\"947\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2c7\/9c9\/f40\/2c79c9f408aaa3e2fe691c3313197029.png\"\/><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 MIDI-\u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/mido.readthedocs.io\/en\/stable\/\" rel=\"noopener noreferrer nofollow\">mido<\/a>.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c!<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0442\u044b \u0441 velocity(\u0441\u0438\u043b\u0430 \u0443\u0434\u0430\u0440\u0430 \u043f\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u0443) \u0438 time(\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c), \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0430\u044f \u043f\u0430\u0440\u0442\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0436\u0438\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def get_notes_from_midi(filename):     notes = []     midi = MidiFile(filename)      for track in midi.tracks:         for message in track:             if message.type == 'note_on' or message.type == 'note_off':                 type = message.type                 note = message.note                 velocity = message.velocity                 time = message.time                 notes.append((type, note, velocity, time))      return notes<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_unique_id_dict(dataset):     note_dict = {}     unique_set = []     sequence_id = 0     time = 0      for i in range(len(dataset)-1):         item = dataset[i]         time += item[3]          unique_set.append(item)          if time >= 1900:             sequence_id += 1             note_dict[sequence_id] = unique_set             unique_set = []             time = 0             continue      return note_dict  def reindex_dict(note_dict):     unique_dict = {}     i = 1     for key, value in note_dict.items():         if value not in unique_dict.values():             unique_dict[i] = value             i += 1     return unique_dict <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043d\u043e\u0442\u044b \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def replace_notes_with_ids(notes, note_dict):     id_notes = []     for note in notes:         for key, value in note_dict.items():             if note in value:                 id_notes.append(key)                 break     return id_notes<\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0437 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_dict(notes):     unique_notes = list(set(notes))     return {note: index for index, note in enumerate(unique_notes)}<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def prepare_sequences(notes, note_dict):     sequence_length = 64     sequence_input = []     sequence_output = []      # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u043e\u0442     index_dict = {note: index for index, note in enumerate(note_dict)}      for i in range(len(notes) - sequence_length):         sequence_in = notes[i: i + sequence_length]         sequence_out = notes[i + sequence_length]          sequence_input.append([index_dict[note] for note in sequence_in])          if sequence_out in index_dict:             sequence_output.append(index_dict[sequence_out])      x = np.reshape(sequence_input, (len(sequence_input), sequence_length, 1))     y = to_categorical(sequence_output, num_classes=len(note_dict))      return x, y<\/code><\/pre>\n<ol start=\"6\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c. <\/p>\n<p><em>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c\u044e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <\/em><a href=\"https:\/\/keras.io\/\" rel=\"noopener noreferrer nofollow\"><em>keras<\/em><\/a><\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_network(input_dim, num_features):     model = tf.keras.Sequential()     model.add(layers.LSTM(128, input_shape=(None, input_dim)))     model.add(layers.Dense(64, activation='relu'))     model.add(layers.Dense(64, activation='relu'))     model.add(layers.Dense(num_features, activation='sigmoid'))     model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])     return model   def train(model, input_data, output_data, epochs=20, batch_size=64, name='data'):     model.fit(input_data, output_data, epochs=epochs, batch_size=batch_size)     model.save('models\/' + name + '.keras')<\/code><\/pre>\n<ol start=\"7\">\n<li>\n<p>\u0418 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0435 \u043e\u0431\u0443\u0447\u0438\u0442\u044c. \u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<\/li>\n<\/ol>\n<pre><code>data_name = 'funk' notes = get_notes_from_midi('data\/'+data_name+'.mid') note_dict = reindex_dict(create_unique_id_dict(notes))  digital_note = replace_notes_with_ids(notes, note_dict) digital_dict = create_dict(digital_note)  x,y = prepare_sequences(digital_note, digital_dict)  num_features = len(set(digital_dict)) input_dim = 1   model = create_network(input_dim, num_features) train(model, x, y, epochs=50, batch_size=64, name=data_name)<\/code><\/pre>\n<h2>2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u0440\u0442\u0438\u0438<\/h2>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u043e\u0432\u0443\u044e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def gen(count, digital_dict, note_dict, x, data_name):     model = load_model('models\/'+data_name+'.keras')     digital_dict = {value: key for key, value in digital_dict.items()}     new_digital_notes = []     new_notes = []      for i in range(count):         prediction_output = predict(model, x)         digital_notes = get_notes(prediction_output, digital_dict)         new_digital_notes.append(digital_notes)       for notes in new_digital_notes:         for id in notes:             new_notes.append(note_dict[id])       print(new_notes)      create_midi_file(new_notes, 'out\/'+data_name+'.mid')<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0442 \u0432 MIDI \u0444\u043e\u0440\u043c\u0430\u0442. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0438\u0437 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f MIDI.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def predict(model, x):     start = np.random.randint(0, len(x) - 1)     pattern = x[start]     prediction_output = []      for note_index in range(64):         prediction_input = np.reshape(pattern, (1, len(pattern), 1))         prediction = model.predict(prediction_input)         predicted_note = np.argmax(prediction)         prediction_output.append(predicted_note)          pattern = np.append(pattern, predicted_note)         pattern = pattern[1:len(pattern)]      return prediction_output   def get_notes(prediction_output, dict):     notes = []     for id in prediction_output:         notes.append(dict[id])      return notes   def create_midi_file(notes, output_filename, ticks_per_beat=960, tempo=500000):     midi = MidiFile(ticks_per_beat=ticks_per_beat)     track = MidiTrack()     midi.tracks.append(track)     tempo = mido.bpm2tempo(120)      track.append(MetaMessage('set_tempo', tempo=tempo))      for items in notes:         for note in items:             track.append(Message(note[0], note=note[1], velocity=note[2], time=note[3]))      midi.save(output_filename)<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e. \u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ol>\n<pre><code>data_name = 'funk' notes = get_notes_from_midi('data\/'+data_name+'.mid') note_dict = reindex_dict(create_unique_id_dict(notes))  digital_note = replace_notes_with_ids(notes, note_dict) digital_dict = create_dict(digital_note)  x, y = prepare_sequences(digital_note, digital_dict)  gen(1, digital_dict, note_dict, x, data_name)<\/code><\/pre>\n<h2>3. \u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441\u0432\u043e\u044e \u0438\u0434\u0435\u044e. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u043e\u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u043d\u0435 \u043d\u043e\u0442, \u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u0443\u0437\u044b\u043a\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u044d\u0442\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u0430 \u0443\u0434\u0430\u0440\u043e\u0432 \u043f\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u0443 \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u043e\u0442. \u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0432\u0443\u0447\u0430\u0442\u044c, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0435\u0435 \u0438\u0433\u0440\u0430\u043b \u0436\u0438\u0432\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a.<\/p>\n<p>\u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0432\u043e\u0442 <a href=\"https:\/\/github.com\/Alex-Kuimov\/generhythm\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0433\u0438\u0442\u0435<\/a>. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0436\u0438\u0432\u0443\u044e, \u0432\u043e\u0442 <a href=\"https:\/\/ai-beat.ru\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>. <\/p>\n<p><em>P.S. \u041d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e, \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442. \u042f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0436\u0434\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/755562\/\"> https:\/\/habr.com\/ru\/articles\/755562\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042f \u0443\u0432\u043b\u0435\u043a\u0430\u044e\u0441\u044c \u043c\u0443\u0437\u044b\u043a\u043e\u0439 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0438 \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441\u0432\u043e\u0438 \u0434\u0432\u0430 \u0445\u043e\u0431\u0431\u0438. \u0423 \u043c\u0435\u043d\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0434\u0435\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0442\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 MIDI. \u042d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0443\u0437\u044b\u043a\u0438. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u0441\u043c\u043e\u0433 \u0441\u043e\u0437\u0434\u0430\u0442\u044c.<\/p>\n<h2>1. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b MIDI-\u0444\u0430\u0439\u043b\u044b \u0441 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0442\u0438\u044f\u043c\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/Alex-Kuimov\/generhythm\/tree\/master\/data\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0442\u0443\u0442<\/a>.  \u0412\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043d\u043e\u0442\u0430\u043c\u0438, \u044f \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 &#8212; \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f. <\/p>\n<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 MIDI-\u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/mido.readthedocs.io\/en\/stable\/\" rel=\"noopener noreferrer nofollow\">mido<\/a>.<\/p>\n<p>\u0418 \u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c!<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0442\u044b \u0441 velocity(\u0441\u0438\u043b\u0430 \u0443\u0434\u0430\u0440\u0430 \u043f\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u0443) \u0438 time(\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c), \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0430\u044f \u043f\u0430\u0440\u0442\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0436\u0438\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def get_notes_from_midi(filename):     notes = []     midi = MidiFile(filename)      for track in midi.tracks:         for message in track:             if message.type == 'note_on' or message.type == 'note_off':                 type = message.type                 note = message.note                 velocity = message.velocity                 time = message.time                 notes.append((type, note, velocity, time))      return notes<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_unique_id_dict(dataset):     note_dict = {}     unique_set = []     sequence_id = 0     time = 0      for i in range(len(dataset)-1):         item = dataset[i]         time += item[3]          unique_set.append(item)          if time >= 1900:             sequence_id += 1             note_dict[sequence_id] = unique_set             unique_set = []             time = 0             continue      return note_dict  def reindex_dict(note_dict):     unique_dict = {}     i = 1     for key, value in note_dict.items():         if value not in unique_dict.values():             unique_dict[i] = value             i += 1     return unique_dict <\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043d\u043e\u0442\u044b \u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def replace_notes_with_ids(notes, note_dict):     id_notes = []     for note in notes:         for key, value in note_dict.items():             if note in value:                 id_notes.append(key)                 break     return id_notes<\/code><\/pre>\n<ol start=\"4\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0438\u0437 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_dict(notes):     unique_notes = list(set(notes))     return {note: index for index, note in enumerate(unique_notes)}<\/code><\/pre>\n<ol start=\"5\">\n<li>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def prepare_sequences(notes, note_dict):     sequence_length = 64     sequence_input = []     sequence_output = []      # \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u043e\u0442     index_dict = {note: index for index, note in enumerate(note_dict)}      for i in range(len(notes) - sequence_length):         sequence_in = notes[i: i + sequence_length]         sequence_out = notes[i + sequence_length]          sequence_input.append([index_dict[note] for note in sequence_in])          if sequence_out in index_dict:             sequence_output.append(index_dict[sequence_out])      x = np.reshape(sequence_input, (len(sequence_input), sequence_length, 1))     y = to_categorical(sequence_output, num_classes=len(note_dict))      return x, y<\/code><\/pre>\n<ol start=\"6\">\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c. <\/p>\n<p><em>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c\u044e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <\/em><a href=\"https:\/\/keras.io\/\" rel=\"noopener noreferrer nofollow\"><em>keras<\/em><\/a><\/p>\n<\/li>\n<\/ol>\n<pre><code>def create_network(input_dim, num_features):     model = tf.keras.Sequential()     model.add(layers.LSTM(128, input_shape=(None, input_dim)))     model.add(layers.Dense(64, activation='relu'))     model.add(layers.Dense(64, activation='relu'))     model.add(layers.Dense(num_features, activation='sigmoid'))     model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])     return model   def train(model, input_data, output_data, epochs=20, batch_size=64, name='data'):     model.fit(input_data, output_data, epochs=epochs, batch_size=batch_size)     model.save('models\/' + name + '.keras')<\/code><\/pre>\n<ol start=\"7\">\n<li>\n<p>\u0418 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0435 \u043e\u0431\u0443\u0447\u0438\u0442\u044c. \u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<\/li>\n<\/ol>\n<pre><code>data_name = 'funk' notes = get_notes_from_midi('data\/'+data_name+'.mid') note_dict = reindex_dict(create_unique_id_dict(notes))  digital_note = replace_notes_with_ids(notes, note_dict) digital_dict = create_dict(digital_note)  x,y = prepare_sequences(digital_note, digital_dict)  num_features = len(set(digital_dict)) input_dim = 1   model = create_network(input_dim, num_features) train(model, x, y, epochs=50, batch_size=64, name=data_name)<\/code><\/pre>\n<h2>2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u0440\u0442\u0438\u0438<\/h2>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u043e\u0432\u0443\u044e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def gen(count, digital_dict, note_dict, x, data_name):     model = load_model('models\/'+data_name+'.keras')     digital_dict = {value: key for key, value in digital_dict.items()}     new_digital_notes = []     new_notes = []      for i in range(count):         prediction_output = predict(model, x)         digital_notes = get_notes(prediction_output, digital_dict)         new_digital_notes.append(digital_notes)       for notes in new_digital_notes:         for id in notes:             new_notes.append(note_dict[id])       print(new_notes)      create_midi_file(new_notes, 'out\/'+data_name+'.mid')<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0442 \u0432 MIDI \u0444\u043e\u0440\u043c\u0430\u0442. \u0410 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0438\u0437 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f MIDI.<\/p>\n<\/li>\n<\/ol>\n<pre><code>def predict(model, x):     start = np.random.randint(0, len(x) - 1)     pattern = x[start]     prediction_output = []      for note_index in range(64):         prediction_input = np.reshape(pattern, (1, len(pattern), 1))         prediction = model.predict(prediction_input)         predicted_note = np.argmax(prediction)         prediction_output.append(predicted_note)          pattern = np.append(pattern, predicted_note)         pattern = pattern[1:len(pattern)]      return prediction_output   def get_notes(prediction_output, dict):     notes = []     for id in prediction_output:         notes.append(dict[id])      return notes   def create_midi_file(notes, output_filename, ticks_per_beat=960, tempo=500000):     midi = MidiFile(ticks_per_beat=ticks_per_beat)     track = MidiTrack()     midi.tracks.append(track)     tempo = mido.bpm2tempo(120)      track.append(MetaMessage('set_tempo', tempo=tempo))      for items in notes:         for note in items:             track.append(Message(note[0], note=note[1], velocity=note[2], time=note[3]))      midi.save(output_filename)<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e. \u0412\u043e\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u0434.<\/p>\n<\/li>\n<\/ol>\n<pre><code>data_name = 'funk' notes = get_notes_from_midi('data\/'+data_name+'.mid') note_dict = reindex_dict(create_unique_id_dict(notes))  digital_note = replace_notes_with_ids(notes, note_dict) digital_dict = create_dict(digital_note)  x, y = prepare_sequences(digital_note, digital_dict)  gen(1, digital_dict, note_dict, x, data_name)<\/code><\/pre>\n<h2>3. \u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u0441\u0432\u043e\u044e \u0438\u0434\u0435\u044e. \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u043e\u043d\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u043d\u0435 \u043d\u043e\u0442, \u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u0443\u0437\u044b\u043a\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u044d\u0442\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u0430 \u0443\u0434\u0430\u0440\u043e\u0432 \u043f\u043e \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u0443 \u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u043e\u0442. \u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0431\u0430\u0440\u0430\u0431\u0430\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0432\u0443\u0447\u0430\u0442\u044c, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0435\u0435 \u0438\u0433\u0440\u0430\u043b \u0436\u0438\u0432\u043e\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a.<\/p>\n<p>\u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0432\u043e\u0442 <a href=\"https:\/\/github.com\/Alex-Kuimov\/generhythm\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0433\u0438\u0442\u0435<\/a>. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0436\u0438\u0432\u0443\u044e, \u0432\u043e\u0442 <a href=\"https:\/\/ai-beat.ru\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>. <\/p>\n<p><em>P.S. \u041d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e, \u044d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442. \u042f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u0436\u0434\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/755562\/\"> https:\/\/habr.com\/ru\/articles\/755562\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-352589","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=352589"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352589\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=352589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=352589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=352589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}