From 7cf85f41e7b26423900f562a383c8c77158938e4 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:10:09 -0400 Subject: [PATCH 01/11] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 630679a..a1b11f3 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,17 @@ All AI Club projects in Fall 2022 ## 5. [Basic prediction models](#) ## 6. [Spotify personality predictor](#) - +

+ This project ultilizes data collected from our friends Spotify accounts. We use their listening history as well as their responses to a personality questionaire to create an accurate dataset. With this dataset, we are training a model to identify a person's personality based on factors prevelent in their music taste. +

+

Project members:

+Zane Aridi +filler +filler +filler +filler +filler +filler ## 7. [AI decryption](#) ## 8. [AI firewall](#) From 62c6dd470fb2b1205b2548a83d45266e3b33ae85 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:10:48 -0400 Subject: [PATCH 02/11] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a1b11f3..cfed5ab 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ All AI Club projects in Fall 2022 filler filler filler +
+ ## 7. [AI decryption](#) ## 8. [AI firewall](#) From 0a0b23b5fed51dfab2f08da9525d731acada8b5f Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:11:39 -0400 Subject: [PATCH 03/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfed5ab..f07c323 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ All AI Club projects in Fall 2022 This project ultilizes data collected from our friends Spotify accounts. We use their listening history as well as their responses to a personality questionaire to create an accurate dataset. With this dataset, we are training a model to identify a person's personality based on factors prevelent in their music taste.

Project members:

-Zane Aridi +Zane Aridi filler filler filler From 8391a63087decacf6f1afc217504f801e7bcdd0a Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:15:39 -0400 Subject: [PATCH 04/11] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f07c323..662aeba 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,12 @@ All AI Club projects in Fall 2022

Project members:

Zane Aridi -filler -filler -filler -filler -filler -filler +Aaryan Walia +Blenda +Brian Kim +Joanna +Mann Aswal +Kevin
## 7. [AI decryption](#) From 12b5fe03e42df757d229cdec1753918002838929 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:19:04 -0400 Subject: [PATCH 05/11] Update README.md --- README.md | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 662aeba..b757c4c 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,33 @@ All AI Club projects in Fall 2022 This project ultilizes data collected from our friends Spotify accounts. We use their listening history as well as their responses to a personality questionaire to create an accurate dataset. With this dataset, we are training a model to identify a person's personality based on factors prevelent in their music taste.

Project members:

-Zane Aridi -Aaryan Walia -Blenda -Brian Kim -Joanna -Mann Aswal -Kevin + + + + + + + + + + + + +
+ Zane Aridi + + Aaryan Walia + + Blenda + + Brian Kim + + Joanna + + Mann Aswal + + Kevin +

## 7. [AI decryption](#) From 65dea6eabc8d73a47464f2a629e90b8ac0b23166 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:19:27 -0400 Subject: [PATCH 06/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b757c4c..5959daa 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ All AI Club projects in Fall 2022

This project ultilizes data collected from our friends Spotify accounts. We use their listening history as well as their responses to a personality questionaire to create an accurate dataset. With this dataset, we are training a model to identify a person's personality based on factors prevelent in their music taste.

-

Project members:

+

Project members:

From 9726d2bbe7e8aca4dbaf671a6fa97d35a8a8c89b Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Sat, 22 Oct 2022 16:11:25 -0400 Subject: [PATCH 07/11] Create SpotifyProject.py --- ProjectSolution/SpotifyProject.py | 123 ++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 ProjectSolution/SpotifyProject.py diff --git a/ProjectSolution/SpotifyProject.py b/ProjectSolution/SpotifyProject.py new file mode 100644 index 0000000..5b43c3b --- /dev/null +++ b/ProjectSolution/SpotifyProject.py @@ -0,0 +1,123 @@ +#import Spotipy +import ast +from typing import List +from os import listdir +import spotipy +import requests +import pandas as pd + +def get_streamings(path: str = 'AData') -> List[dict]: + + files = ['AData/' + x for x in listdir(path) + if x.split('.')[0][:-1] == 'StreamingHistory'] + + all_streamings = [] + totalTimeByTrack = {} + + for file in files: + with open(file, 'r', encoding='UTF-8') as f: + new_streamings = ast.literal_eval(f.read()) + for streaming in new_streamings: + if streaming['trackName'] in totalTimeByTrack: + totalTimeByTrack[streaming['trackName']] += round(streaming['msPlayed']/60000) + else: + totalTimeByTrack[streaming['trackName']] = round(streaming['msPlayed']/60000) + all_streamings.append(streaming) + return totalTimeByTrack + + +def get_id(track_name: str, token: str) -> str: + headers = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': f'Bearer ' + token, + } + params = [ + ('q', track_name), + ('type', 'track'), + ] + try: + response = requests.get('https://api.spotify.com/v1/search', + headers = headers, params = params, timeout = 5) + json = response.json() + first_result = json['tracks']['items'][0] + track_id = first_result['id'] + return track_id + except: + return None + + +def get_features(track_id: str, token: str) -> dict: + sp = spotipy.Spotify(auth=token) + try: + features = sp.audio_features([track_id]) + return features[0] + except: + return None + +def trim_features(features: dict) -> dict: + # TODO: Only grab certain features + pass + + +#get_streamings() + +username = 'qut9zcs5mbfdmc5cykwudcjtj' +client_id = '248c415c42004414acfa6cc8fe305bc3' +client_secret = 'acb2bbbec3184747b5851fa482419ade' +redirect_url = 'http://localhost:7777/callback' +scope = 'user-read-recently-played' + +token = spotipy.util.prompt_for_user_token(username=username, + scope=scope, + client_id=client_id, + client_secret=client_secret, + redirect_uri=redirect_url) + +streamings = get_streamings() +sortedListByStreamingTimes = sorted([x for x in streamings.values()]) +topX = int(len(sortedListByStreamingTimes)*.5) +dataset = pd.DataFrame() + +featureFinalValues = {} +for streamingName,timePlayed in streamings.items(): + if timePlayed < sortedListByStreamingTimes[topX]: + continue + + ID = get_id(streamingName,token) + + # TODO: Make function to extract features we care about + features = get_features(ID,token) + + # TODO: Grab genere + + # get averages for each value in feature_avgs + for key,value in features.items(): + + if key in featureFinalValues: + featureFinalValues[key][0] += value*timePlayed + featureFinalValues[key][1] += timePlayed + else: + featureFinalValues[key] = [value*timePlayed,timePlayed] + + + # Associtae indexs + bigFive = [50,50,50,50,50] + + + + +#print("Streamings:",streamings) +#print("\nID:",ID) +#print("\nfeatures",features) + +# ID 1 +# Dictionary where ID is the key +# the value will be a tuple +# two dictionaries +# Dict1 will have all a person songs that are in the top 75% of their listening. +# Keys for this dictioanry will be the song name and value will be a tuple of time listen to in total and the artist name + + +# ITF dictionary 2 od the tuple will be the quetion number ids and participant responses + From 58595eff7031e4a0804b1a285f453a77c7ccb4ff Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:12:29 -0400 Subject: [PATCH 08/11] Update README.md --- README.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0f93265..cf3a89e 100644 --- a/README.md +++ b/README.md @@ -210,25 +210,47 @@ A Fetal State Predictor that will predict fetal state whether it's normal suspec From a1ad9784603cc7a815192e24aec6f74541188233 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:22:53 -0400 Subject: [PATCH 09/11] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index cf3a89e..132c4e3 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,6 @@ A Fetal State Predictor that will predict fetal state whether it's normal suspec Mann Aswal
- Zane Aridi + + +
+ Zane Aridi
- Aaryan Walia + + +
+ Aaryan Walia
- Blenda + + +
+ Blenda
- Brian Kim + + +
+ Brian Kim
- Joanna + + +
+ Joanna
- Mann Aswal + + +
+ Mann Aswal
Kevin + + +
+ Kevin
- Kevin
From 311fe9eefecb359a635d146f4e8625f64f01ef36 Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:26:59 -0400 Subject: [PATCH 10/11] Delete SpotifyProject.py --- ProjectSolution/SpotifyProject.py | 123 ------------------------------ 1 file changed, 123 deletions(-) delete mode 100644 ProjectSolution/SpotifyProject.py diff --git a/ProjectSolution/SpotifyProject.py b/ProjectSolution/SpotifyProject.py deleted file mode 100644 index 5b43c3b..0000000 --- a/ProjectSolution/SpotifyProject.py +++ /dev/null @@ -1,123 +0,0 @@ -#import Spotipy -import ast -from typing import List -from os import listdir -import spotipy -import requests -import pandas as pd - -def get_streamings(path: str = 'AData') -> List[dict]: - - files = ['AData/' + x for x in listdir(path) - if x.split('.')[0][:-1] == 'StreamingHistory'] - - all_streamings = [] - totalTimeByTrack = {} - - for file in files: - with open(file, 'r', encoding='UTF-8') as f: - new_streamings = ast.literal_eval(f.read()) - for streaming in new_streamings: - if streaming['trackName'] in totalTimeByTrack: - totalTimeByTrack[streaming['trackName']] += round(streaming['msPlayed']/60000) - else: - totalTimeByTrack[streaming['trackName']] = round(streaming['msPlayed']/60000) - all_streamings.append(streaming) - return totalTimeByTrack - - -def get_id(track_name: str, token: str) -> str: - headers = { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': f'Bearer ' + token, - } - params = [ - ('q', track_name), - ('type', 'track'), - ] - try: - response = requests.get('https://api.spotify.com/v1/search', - headers = headers, params = params, timeout = 5) - json = response.json() - first_result = json['tracks']['items'][0] - track_id = first_result['id'] - return track_id - except: - return None - - -def get_features(track_id: str, token: str) -> dict: - sp = spotipy.Spotify(auth=token) - try: - features = sp.audio_features([track_id]) - return features[0] - except: - return None - -def trim_features(features: dict) -> dict: - # TODO: Only grab certain features - pass - - -#get_streamings() - -username = 'qut9zcs5mbfdmc5cykwudcjtj' -client_id = '248c415c42004414acfa6cc8fe305bc3' -client_secret = 'acb2bbbec3184747b5851fa482419ade' -redirect_url = 'http://localhost:7777/callback' -scope = 'user-read-recently-played' - -token = spotipy.util.prompt_for_user_token(username=username, - scope=scope, - client_id=client_id, - client_secret=client_secret, - redirect_uri=redirect_url) - -streamings = get_streamings() -sortedListByStreamingTimes = sorted([x for x in streamings.values()]) -topX = int(len(sortedListByStreamingTimes)*.5) -dataset = pd.DataFrame() - -featureFinalValues = {} -for streamingName,timePlayed in streamings.items(): - if timePlayed < sortedListByStreamingTimes[topX]: - continue - - ID = get_id(streamingName,token) - - # TODO: Make function to extract features we care about - features = get_features(ID,token) - - # TODO: Grab genere - - # get averages for each value in feature_avgs - for key,value in features.items(): - - if key in featureFinalValues: - featureFinalValues[key][0] += value*timePlayed - featureFinalValues[key][1] += timePlayed - else: - featureFinalValues[key] = [value*timePlayed,timePlayed] - - - # Associtae indexs - bigFive = [50,50,50,50,50] - - - - -#print("Streamings:",streamings) -#print("\nID:",ID) -#print("\nfeatures",features) - -# ID 1 -# Dictionary where ID is the key -# the value will be a tuple -# two dictionaries -# Dict1 will have all a person songs that are in the top 75% of their listening. -# Keys for this dictioanry will be the song name and value will be a tuple of time listen to in total and the artist name - - -# ITF dictionary 2 od the tuple will be the quetion number ids and participant responses - From 5182814223b0efe277d4b8d4e944ba25e913a5dc Mon Sep 17 00:00:00 2001 From: ZaneAridi1022 <80779298+ZaneAridi1022@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:08:58 -0400 Subject: [PATCH 11/11] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index cc4784d..57defb0 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,6 @@ A Fetal State Predictor that will predict fetal state whether it's normal suspec

This project ultilizes data collected from our friends Spotify accounts. We use their listening history as well as their responses to a personality questionaire to create an accurate dataset. With this dataset, we are training a model to identify a person's personality based on factors prevelent in their music taste.

-

Project members: