Spaces:
Build error
Build error
| import gradio as gr | |
| import random | |
| # List of FM radio frequencies and their corresponding names | |
| radio_frequencies = { | |
| "87.5": "HugFace Music", | |
| "88.6": "Dance FM", | |
| "89.1": "Special Radio", | |
| "91.2": "Bob M. Reggae", | |
| "95.1": "Free Listen 1", | |
| "98.1": "Free Listen 2", | |
| "100.2": "R N R", | |
| } | |
| # List of AM radio frequencies and their corresponding names | |
| AMradio_frequencies = { | |
| "539": "Alternate Frequencies", | |
| "721": "Free Listen AM", | |
| "871": "Time after Time Stories", | |
| "923": "Clueless AM", | |
| "1123": "Love and Time", | |
| } | |
| # Function to create and launch the Gradio interface | |
| def create_and_launch_interface(): | |
| # Function to simulate a radio broadcast with dialogues | |
| def simulate_radio_broadcast(frequency): | |
| if frequency in radio_frequencies: | |
| radio_name = radio_frequencies[frequency] | |
| intro = f"Welcome to {radio_name} on {frequency} FM!" | |
| dialogue_options = [ | |
| "Get ready for a fantastic playlist!", | |
| "Stay tuned for the latest news updates.", | |
| "We have a special surprise coming up, so don't change that dial!", | |
| "Call in and let us know your favorite song!", | |
| "Good evening, listeners! This is the station where the rhythm never stops and the stories keep you hooked.", | |
| "Stay tuned for more beats and stories that'll keep you on your toes on this radio show!" | |
| ] | |
| outro = random.choice(["Thanks for tuning in!", "Hope you're enjoying the broadcast!", "Keep rocking with us!"]) | |
| elif frequency in AMradio_frequencies: | |
| radio_name = AMradio_frequencies[frequency] | |
| intro = f"Welcome to {radio_name} on {frequency} AM!" | |
| dialogue_options = [ | |
| "Get ready for an insightful discussion!", | |
| "Explore the fascinating world of AM radio.", | |
| "We have interesting stories lined up for you.", | |
| "Join us for a journey through time and tales.", | |
| ] | |
| outro = random.choice(["Thanks for tuning in!", "Hope you enjoy the AM broadcast!", "Stay tuned for more on AM!"]) | |
| else: | |
| return "Invalid frequency. Please choose a valid radio station." | |
| return f"{intro} {random.choice(dialogue_options)} {outro}" | |
| # Create Gradio interface with a "Tune In" button | |
| iface = gr.Interface( | |
| fn=simulate_radio_broadcast, | |
| inputs=gr.Dropdown(list(radio_frequencies.keys()) + list(AMradio_frequencies.keys()), label="Select Radio Frequency"), | |
| outputs="text", | |
| live=True, | |
| title="Simulated Radio Broadcast", | |
| description="Experience the excitement of a virtual radio broadcast(note:does not recieve actual radio signals).", | |
| ) | |
| # Launch the Gradio app | |
| iface.launch() | |
| # Create and launch the interface | |
| create_and_launch_interface() | |