Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
import streamlit.components.v1 as components
|
|
|
|
|
3 |
|
4 |
# Function to generate HTML with textarea for speech synthesis
|
5 |
def generate_speech_textarea(text_to_speak):
|
6 |
-
#st.markdown(text_to_speak)
|
7 |
documentHTML5 = '''
|
8 |
<!DOCTYPE html>
|
9 |
<html>
|
@@ -29,55 +30,49 @@ def generate_speech_textarea(text_to_speak):
|
|
29 |
</html>
|
30 |
'''
|
31 |
components.html(documentHTML5, width=1280, height=500)
|
32 |
-
|
33 |
-
# Game list and associated icons
|
34 |
-
games = ['Terraforming Mars', 'Twilight Imperium (Fourth Edition)', 'Scythe', 'Eclipse', 'Small World', 'Risk Legacy', 'Axis & Allies', 'Diplomacy', 'Pandemic Legacy: Season 1', 'Brass: Birmingham']
|
35 |
-
icons = ['πͺ', 'π', 'π€', 'π', 'π§ββοΈ', 'πΊοΈ', 'βοΈ', 'π€', 'π¦ ', 'π']
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
#
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
-
|
|
|
|
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
st.markdown(text_to_speak)
|
52 |
-
elif game == 'Twilight Imperium (Fourth Edition)':
|
53 |
-
text_to_speak = "ππ **Twilight Imperium** \n1οΈβ£ πβοΈ Position fleets in strategic nebulas and balance resources \n2οΈβ£ π°π‘οΈ Fortify chokepoints and use PDS systems \n3οΈβ£ ππ Effective trade routes and wormhole caution \n4οΈβ£ ππ Prioritize Mecatol Rex and moon attacks \n5οΈβ£ π οΈπ€ Optimize unit upgrades and forge alliances."
|
54 |
-
st.markdown(text_to_speak)
|
55 |
-
elif game == 'Scythe':
|
56 |
-
text_to_speak = "π€ποΈ **Scythe** \n1οΈβ£ ποΈπ οΈ Choose starting positions and factory cards \n2οΈβ£ πΊοΈπ Be aware of neighbors and control rivers \n3οΈβ£ ππ‘οΈ Maximize resource buildings and backdoor defense \n4οΈβ£ π―πΎ Focus objectives and manage food \n5οΈβ£ π²π Play probabilities and hunt treasures."
|
57 |
-
st.markdown(text_to_speak)
|
58 |
-
elif game == 'Eclipse':
|
59 |
-
text_to_speak = "ππ **Eclipse** \n1οΈβ£ ππ Control sectors and central hexes \n2οΈβ£ πΈπ‘οΈ Build formidable fleets and defenses \n3οΈβ£ ππ Prioritize production and research \n4οΈβ£ π€π Trade and diplomacy \n5οΈβ£ ππ Wormhole travel and expansion speed."
|
60 |
-
st.markdown(text_to_speak)
|
61 |
-
elif game == 'Small World':
|
62 |
-
text_to_speak = "π§ββοΈπ **Small World** \n1οΈβ£ πΊοΈπ Choose realms and races wisely \n2οΈβ£ ππ‘οΈ Exploit powers and defend territories \n3οΈβ£ ππ Collect victory coins and treasures \n4οΈβ£ π€π Forge short alliances and occupy mountains \n5οΈβ£ ππ° Know when to decline and occupy forts."
|
63 |
-
st.markdown(text_to_speak)
|
64 |
-
elif game == 'Risk Legacy':
|
65 |
-
text_to_speak = "πΊοΈβοΈ **Risk Legacy** \n1οΈβ£ πΊοΈβοΈ Control continents and aggressive expansion \n2οΈβ£ π‘οΈπ Fortify borders and use fortresses \n3οΈβ£ ππ Complete missions and airfields \n4οΈβ£ ππ₯ Collect victory points and scorched earth \n5οΈβ£ π€π Alliances and betrayal."
|
66 |
-
st.markdown(text_to_speak)
|
67 |
-
elif game == 'Axis & Allies':
|
68 |
-
text_to_speak = "βοΈπ **Axis & Allies** \n1οΈβ£ βοΈπ Strategic frontlines and global dominance \n2οΈβ£ ππ Resource management and economy \n3οΈβ£ π‘οΈπ’ Naval blockades and fortress defenses \n4οΈβ£ ποΈπ― Focused objectives and key battles \n5οΈβ£ π€π₯ Alliances and surprise attacks."
|
69 |
-
st.markdown(text_to_speak)
|
70 |
-
elif game == 'Diplomacy':
|
71 |
-
text_to_speak = "π€π **Diplomacy** \n1οΈβ£ π€π Negotiation and written orders \n2οΈβ£ πΊοΈπ‘οΈ Strategic positioning and defenses \n3οΈβ£ π’β Naval forces and chokepoints \n4οΈβ£ π°π Territory control and key regions \n5οΈβ£ ππ Timing and deception."
|
72 |
-
st.markdown(text_to_speak)
|
73 |
-
elif game == 'Pandemic Legacy: Season 1':
|
74 |
-
text_to_speak = "π¦ π **Pandemic Legacy** \n1οΈβ£ π¦ π¬ Cure research and outbreak control \n2οΈβ£ ππ Global movement and airlifts \n3οΈβ£ π₯π‘οΈ Build research stations and quarantine \n4οΈβ£ ππ― Complete objectives and bonus cards \n5οΈβ£ π€π Teamwork and role synergy."
|
75 |
-
st.markdown(text_to_speak)
|
76 |
-
elif game == 'Brass: Birmingham':
|
77 |
-
text_to_speak = "ππ€οΈ **Brass Birmingham** \n1οΈβ£ ππ€οΈ Industry and canal routes \n2οΈβ£ ππΊ Economic management and beer supply \n3οΈβ£ π οΈπΊοΈ Optimize developments and map control \n4οΈβ£ π€π‘ Partnerships and market strategy \n5οΈβ£ ππ Railroads and victory points."
|
78 |
-
st.markdown(text_to_speak)
|
79 |
|
80 |
-
|
|
|
81 |
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import streamlit.components.v1 as components
|
3 |
+
import geopandas as gpd
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
|
6 |
# Function to generate HTML with textarea for speech synthesis
|
7 |
def generate_speech_textarea(text_to_speak):
|
|
|
8 |
documentHTML5 = '''
|
9 |
<!DOCTYPE html>
|
10 |
<html>
|
|
|
30 |
</html>
|
31 |
'''
|
32 |
components.html(documentHTML5, width=1280, height=500)
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
# Function to display the state outline
|
35 |
+
def plot_state_outline(state_code):
|
36 |
+
# Read U.S. geometries file
|
37 |
+
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
|
38 |
+
# Filter data for the given state
|
39 |
+
gdf_state = gdf[gdf['iso_a3'] == 'USA']
|
40 |
+
# Plot the geometry
|
41 |
+
ax = gdf_state.boundary.plot()
|
42 |
+
plt.title(f"{state_code} State Outline")
|
43 |
+
st.pyplot(plt)
|
44 |
|
45 |
+
# States list and associated icons
|
46 |
+
states = ['MN', 'CA', 'WA', 'FL', 'TX', 'NY', 'NV']
|
47 |
+
icons = ['π¦', 'π΄', 'π', 'π', 'π€ ', 'π½', 'π°']
|
48 |
|
49 |
+
# Main code
|
50 |
+
st.title('U.S. States Trivia πΊοΈ')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
for i, (state, icon) in enumerate(zip(states, icons)):
|
53 |
+
st.markdown(f"{i + 1}. {state} {icon}")
|
54 |
|
55 |
+
# Expanders for each state to outline fascinating facts
|
56 |
+
with st.expander(f"See Fascinating Facts about {state}"):
|
57 |
+
text_to_speak = ""
|
58 |
+
|
59 |
+
if state == 'MN':
|
60 |
+
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."
|
61 |
+
elif state == 'CA':
|
62 |
+
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."
|
63 |
+
elif state == 'WA':
|
64 |
+
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."
|
65 |
+
elif state == 'FL':
|
66 |
+
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."
|
67 |
+
elif state == 'TX':
|
68 |
+
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."
|
69 |
+
elif state == 'NY':
|
70 |
+
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."
|
71 |
+
elif state == 'NV':
|
72 |
+
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."
|
73 |
+
|
74 |
+
st.markdown(text_to_speak)
|
75 |
+
plot_state_outline(state)
|
76 |
+
|
77 |
+
if st.button(f"π Read {state}'s Facts Aloud"):
|
78 |
+
generate_speech_textarea(text_to_speak)
|