# from transformers import pipeline # import gradio as gr # AIzaSyDeT8V0nRlVEgmb0fMK4uc0ci8fAcS0Olg # pipe = pipeline(model="sanchit-gandhi/whisper-small-hi") # change to "your-username/the-name-you-picked" import requests import json import gradio as gr import requests import base64 import json import sys from fetchPlaylistTrackUris import * import re import asyncio # import streamlit.components.v1 as components import pickle import sklearn.preprocessing as pp from scipy.sparse import csr_matrix import numpy as np import pandas as pd import os from scipy.sparse import vstack from recommender import * # gmaps_api_key = os.environ["GMAPS_API"] # transl_api_key= os.environ["TRANS_API"] # gmaps.configure(api_key=gmaps_api_key) # mode = "walking" def test(playlist_url, n_rec): n_rec = int(n_rec) # playlist_url = "https://open.spotify.com/playlist/7HkaNKWr0GCEznuFSEE67i" playlist_uri = playlist_url.split('/')[-1] list_uri = get_playlist_track_uris(playlist_uri) # uri = "spotify:track:5bjWdBx64POBYiUny759hy" # uri_link = "https://open.spotify.com/embed/track/" + uri + "?utm_source=generator&theme=0" # uri_link = "https://open.spotify.com/embed/track/5bjWdBx64POBYiUny759hy?utm_source=generator&theme=0" # components.iframe(uri_link, height=80) # i += 1 # if i % 5 == 0: # time.sleep(1) uri_links = inference_from_uri(list_uri, MAX_tid=n_rec) # uri_links = [] frames = "" for uri_link in uri_links: uri_id = uri_link.split(':')[-1] frames = f'{frames}' return frames with gr.Blocks() as app: # global mode url = gr.Textbox(label="Link to playlist") n_rec = gr.Number(value=5,label="Number of recommendations") btn = gr.Button(value="Submit") ifr = gr.HTML() btn.click(test, inputs=[url, n_rec], outputs=[ifr]) demo = gr.TabbedInterface([app], ["Playlist continuation"]) demo.launch() # def main(): # spr_sidebar() # if st.session_state.app_mode == 'Home': # home_page() # if st.session_state.app_mode == 'Result': # result_page() # if st.session_state.app_mode == 'About' : # About_page() # if st.session_state.app_mode == 'Log': # Log_page() # # Run main() # if __name__ == '__main__': # main()