How to use list_keys method in localstack

Best Python code snippet using localstack_python

harmony_predictor.py

Source:harmony_predictor.py Github

copy

Full Screen

1import spotipy2from spotipy.oauth2 import SpotifyOAuth3import cred4import Harmony as harm5import time6import musicalbeeps7import numpy as np8import threading9scope = "user-read-playback-state,user-modify-playback-state"10sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))11player = musicalbeeps.Player(volume = 0.3, mute_output = False)12uri = 'spotify:track:0sY6ZUTh4yoctD8VIXz339'13analysis = sp.audio_analysis(uri)14section_start_times = []15section_durations = []16list_keys = []17list_modes = []18section_tempos = []19section_time_signature = []20song_time_signature = sp.audio_features(uri)[0]['time_signature']21song_tempo = sp.audio_features(uri)[0]['tempo']22song_key = [sp.audio_features(uri)[0]['key']]23song_mode = [sp.audio_features(uri)[0]['mode']]24for section in analysis['sections']:25 section_start_times.append(section['start'])26 section_durations.append(section['duration'])27 list_keys.append(section['key'])28 list_modes.append(section['mode'])29 section_tempos.append(section['tempo'])30 section_time_signature.append(section['time_signature'])31section_start_times = np.array(section_start_times)32section_durations = np.array(section_durations)33section_tempos = np.array(section_tempos)34section_time_signature = np.array(section_time_signature)35section_num_measures = section_durations * (section_tempos/60) / section_time_signature36# section_num_measures = np.round(section_num_measures)37#key mapping to letters38def change_key_abc(list_keys):39 for i in range(len(list_keys)):40 if list_keys[i] == 0:41 list_keys[i] = 'C'42 elif list_keys[i] == 1:43 list_keys[i] = 'C#'44 elif list_keys[i] == 2:45 list_keys[i] = 'D'46 elif list_keys[i] == 3:47 list_keys[i] = 'Eb'48 elif list_keys[i] == 4:49 list_keys[i] = 'E'50 elif list_keys[i] == 5:51 list_keys[i] = 'F'52 elif list_keys[i] == 6:53 list_keys[i] = 'F#'54 elif list_keys[i] == 7:55 list_keys[i] = 'G'56 elif list_keys[i] == 8:57 list_keys[i] = 'G#'58 elif list_keys[i] == 9:59 list_keys[i] = 'A'60 elif list_keys[i] == 10:61 list_keys[i] = 'Bb'62 elif list_keys[i] == 11:63 list_keys[i] = 'B'64 return list_keys65def change_mode(list_modes):66 for i in range(len(list_modes)):67 if list_modes[i] == 0:68 list_modes[i] = 'Minor'69 elif list_modes[i] == 1:70 list_modes[i] = "Major"71 return list_modes72def player_thread(chord, note, time_per_measure):73 print('Player %d started' % note)74 musicalbeeps.Player(volume = 0.1, mute_output = False).play_note(tswift_progression[chord][note], time_per_measure)75print(song_mode)76print(change_key_abc(song_key)[0])77sp.start_playback(uris=[uri])78for i in range(len(section_durations)):79 harmony = harm.Harmony(change_key_abc(song_key)[0], change_mode(song_mode)[0])80 tonic_chord = harmony.triad_harmony(change_key_abc(song_key)[0])81 IV_chord = harmony.triad_harmony(harmony.scale[3])82 major_dom_chord = harmony.triad_harmony(harmony.scale[4])83 VI_chord = harmony.triad_harmony(harmony.scale[5])84 tswift_progression = [tonic_chord, major_dom_chord, VI_chord, IV_chord]85 time_per_measure = song_time_signature / song_tempo * 60 * 286 for j in range(int(section_num_measures[i])):87 k = j88 if k > len(tswift_progression) - 1:89 k = j % len(tswift_progression)90 threads = []91 for note in range(len(tswift_progression[k])):92 player = threading.Thread(target = player_thread, args = (k, note, time_per_measure))93 # player.play_note(tswift_progression[k][note], section_durations[i]/section_num_measures[i])94 threads.append(player)95 player.start()96 for thread in threads:97 thread.join()98 print(tswift_progression[k])99# if __name__ == "__main__":100# start_time = time.time()101#102# x = threading.Thread(target=conductor_thread)...

Full Screen

Full Screen

task_5.py

Source:task_5.py Github

copy

Full Screen

1import os2import json3def get_dict_size(path: str):4 dict_sizes = {10 ** i: [0, []] for i in range(2, 10)}5 list_keys = list(dict_sizes.keys())6 if not os.path.exists(path):7 print('Path does not exist!')8 return False9 for root, dirs, files in os.walk(path):10 for file in files:11 size = os.stat(os.path.join(path, file)).st_size12 file_format = file[file.rfind('.') + 1:]13 if size <= list_keys[0]:14 dict_sizes[list_keys[0]][0] += 115 dict_sizes[list_keys[0]][1].append(file_format)16 if list_keys[-1] <= size:17 dict_sizes[list_keys[-1]][0] += 118 dict_sizes[list_keys[-1]][1].append(file_format)19 for i in range(1, len(list_keys)):20 if list_keys[i - 1] <= size <= list_keys[i + 1]:21 dict_sizes[list_keys[i]][0] += 122 dict_sizes[list_keys[i]][1].append(file_format)23 break24 for key in dict_sizes.keys():25 dict_sizes[key] = dict_sizes[key][0], list(set(dict_sizes[key][1]))26 return dict_sizes27if __name__ == '__main__':28 with open('Roman_Morozov_dz_7_summary.json', 'w', encoding='utf-8') as fw:...

Full Screen

Full Screen

task_4.py

Source:task_4.py Github

copy

Full Screen

1import os2def get_dict_size(path: str):3 dict_sizes = {10 ** i: 0 for i in range(2, 10)}4 list_keys = list(dict_sizes.keys())5 if not os.path.exists(path):6 print('Path does not exist!')7 return False8 for root, dirs, files in os.walk(path):9 for file in files:10 size = os.stat(os.path.join(path, file)).st_size11 if size <= list_keys[0]:12 dict_sizes[list_keys[0]] += 113 if list_keys[-1] <= size:14 dict_sizes[list_keys[-1]] += 115 for i in range(1, len(list_keys)):16 if list_keys[i - 1] <= size <= list_keys[i + 1]:17 dict_sizes[list_keys[i]] += 118 break19 return dict_sizes20if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful