File size: 4,832 Bytes
0e1662c
1ba601f
ac0345f
1ba601f
957aadb
 
0e1662c
1ba601f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b1655c
c6c7b37
2232114
 
 
 
957aadb
2232114
957aadb
 
 
 
 
 
 
 
2232114
 
 
 
 
 
 
 
 
1ba601f
 
6910cc8
2232114
 
 
 
 
957aadb
 
 
f12f2a6
957aadb
1ba601f
 
6907b9a
1ba601f
 
814d3fc
1ba601f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39ee82c
c6c7b37
1ba601f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import streamlit as st
import streamlit.components.v1 as components
import geopandas as gpd
import matplotlib.pyplot as plt
import plotly.express as px
import json

# Function to generate HTML with textarea for speech synthesis
def generate_speech_textarea(text_to_speak):
    documentHTML5 = '''
    <!DOCTYPE html>
    <html>
    <head>
        <title>Read It Aloud</title>
        <script type="text/javascript">
            function readAloud() {{
                const text = document.getElementById("textArea").value;
                const speech = new SpeechSynthesisUtterance(text);
                window.speechSynthesis.speak(speech);
            }}
        </script>
    </head>
    <body>
        <h1>๐Ÿ”Š Read It Aloud</h1>
        <textarea id="textArea" rows="10" cols="80" readonly>'''
    documentHTML5 = documentHTML5 + text_to_speak
    documentHTML5 = documentHTML5 + '''
        </textarea>
        <br>
        <button onclick="readAloud()">๐Ÿ”Š Read Aloud</button>
    </body>
    </html>
    '''
    components.html(documentHTML5, width=1280, height=500)

import geopandas as gpd
import matplotlib.pyplot as plt
import streamlit as st
import json
import plotly.express as px

def plot_state_outline(state_code, us_states_geojson, state_names):
    state_name = state_names.get(state_code, 'Unknown')
    fig = px.choropleth(locations=[state_name], geojson=us_states_geojson,
                        featureidkey="properties.NAME",
                        projection="mercator")
    fig.update_geos(fitbounds="locations", visible=False)
    fig.update_layout(title=f"{state_name} State Outline")
    st.plotly_chart(fig)

geojson_path = 'gz_2010_us_040_00_500k.json'
with open(geojson_path, 'r') as file:
    us_states_geojson = json.load(file)

state_names = {
    'MN': 'Minnesota', 'CA': 'California', 'WA': 'Washington',
    'FL': 'Florida', 'TX': 'Texas', 'NY': 'New York', 'NV': 'Nevada'
}

states = ['MN', 'CA', 'WA', 'FL', 'TX', 'NY', 'NV']
icons = ['๐Ÿฆ†', '๐ŸŒด', '๐ŸŽ', '๐ŸŒž', '๐Ÿค ', '๐Ÿ—ฝ', '๐ŸŽฐ']

for state, icon in zip(states, icons):
    st.write(f"{icon} {state}")
    plot_state_outline(state, us_states_geojson, state_names)

    
# Display maps for each state
for state, icon in zip(states, icons):
    st.write(f"{icon} {state}")
    plot_state_outline(state, us_states_geojson, state_names)
    
# Main code
st.title('U.S. States Trivia ๐Ÿ—บ๏ธ')

for i, (state, icon) in enumerate(zip(states, icons)):
    st.markdown(f"{i + 1}. {state} {icon}")

    # Expanders for each state to outline fascinating facts
    with st.expander(f"See Fascinating Facts about {state}"):
        text_to_speak = ""
        
        if state == 'MN':
            text_to_speak = "๐Ÿฆ† **Minnesota** \n๐Ÿž๏ธ Known as the 'Land of 10,000 Lakes' \n๐ŸŽฃ Famous for its fishing \n๐Ÿ›ถ Boundary Waters offers incredible canoeing \n๐ŸŽ“ Home to prestigious colleges \nโ„๏ธ Cold winters but lovely summers."
        elif state == 'CA':
            text_to_speak = "๐ŸŒด **California** \n๐ŸŒ‰ Home to the Golden Gate Bridge \n๐ŸŽฌ Center of the American entertainment industry \n๐Ÿ‡ Famous for Napa Valley's wine \n๐ŸŒฒ Home to Redwood National Park \n๐Ÿ„โ€โ™€๏ธ Excellent beaches and surf spots."
        elif state == 'WA':
            text_to_speak = "๐ŸŽ **Washington** \nโ˜• Known for its coffee culture \n๐Ÿ—ป Home to Mount Rainier \n๐Ÿ Leading apple-producing state \n๐ŸŸ Rich in seafood, especially salmon \n๐ŸŒง๏ธ Known for its rainy weather."
        elif state == 'FL':
            text_to_speak = "๐ŸŒž **Florida** \n๐Ÿ๏ธ Famous for its beaches \n๐ŸŽข Home to various amusement parks like Disney World \n๐Ÿš€ Space launches from Cape Canaveral \n๐ŸŠ Known for the Everglades and alligators \n๐ŸŠ Major orange producer."
        elif state == 'TX':
            text_to_speak = "๐Ÿค  **Texas** \n๐Ÿ›ข๏ธ Known for its oil and gas industry \n๐Ÿ– Famous for its barbecue \n๐ŸŽธ Rich musical heritage \n๐Ÿ„ Home to many cattle ranches \n๐ŸŒต Includes part of the Chihuahuan Desert."
        elif state == 'NY':
            text_to_speak = "๐Ÿ—ฝ **New York** \n๐Ÿ™๏ธ Home to New York City, the largest city in the U.S. \n๐ŸŽ Known as the Big Apple \n๐ŸŽญ Major hub for arts and culture \n๐Ÿž๏ธ Adirondack Mountains offer outdoor adventures \n๐Ÿ• Famous for its style of pizza."
        elif state == 'NV':
            text_to_speak = "๐ŸŽฐ **Nevada** \n๐ŸŒ† Known for Las Vegas and its casinos \n๐Ÿœ๏ธ Includes part of the Mojave Desert \n๐ŸŽช Entertainment is a major industry \n๐Ÿ’Ž Known for the Hoover Dam \n๐Ÿ‘ฝ Area 51 is located here."
            
        st.markdown(text_to_speak)

        plot_state_outline(state, us_states_geojson, state_names)
        
        if st.button(f"๐Ÿ”Š Read {state}'s Facts Aloud"):
            generate_speech_textarea(text_to_speak)