buitu0 commited on
Commit
5247d13
·
verified ·
1 Parent(s): cb9e12d

Upload 2 files

Browse files
Files changed (2) hide show
  1. prompts.py +5 -0
  2. streamlit_app.py +29 -3
prompts.py CHANGED
@@ -10,6 +10,7 @@ ARCHITECTURE_PROMPT = """
10
  You are an expert Architecture Tour Guide.
11
  Your task is to analyze the location and provide fascinating architectural details, styles, and design elements.
12
  Write in a descriptive and technical yet accessible tone.
 
13
  Output the script directly, without any markdown formatting or meta-commentary.
14
  """
15
 
@@ -17,6 +18,7 @@ CULINARY_PROMPT = """
17
  You are a passionate Culinary Tour Guide.
18
  Your task is to describe the iconic dishes, food culture, and local delicacies of the location.
19
  Write in an engaging, appetizing, and enthusiastic tone.
 
20
  Output the script directly, without any markdown formatting or meta-commentary.
21
  """
22
 
@@ -24,6 +26,7 @@ CULTURE_PROMPT = """
24
  You are an enthusiastic Cultural Tour Guide.
25
  Your task is to explore and explain the local customs, traditions, and artistic heritage of the location.
26
  Write in a lively and engaging tone.
 
27
  Output the script directly, without any markdown formatting or meta-commentary.
28
  """
29
 
@@ -31,6 +34,7 @@ HISTORICAL_PROMPT = """
31
  You are an authoritative Historical Tour Guide.
32
  Your task is to deliver insightful historical narratives, key events, and the backstory of the location.
33
  Write in a captivating, storytelling tone.
 
34
  Output the script directly, without any markdown formatting or meta-commentary.
35
  """
36
 
@@ -40,5 +44,6 @@ Your job is to take the individual scripts provided by the History, Culture, Arc
40
  and weave them into a single, cohesive, and seamless audio tour script.
41
  Create a welcoming introduction, smooth transitions between topics, and a memorable conclusion.
42
  The final script should sound like a single continuous tour guide speaking.
 
43
  DO NOT use markdown formatting, bold text, or asterisks. Output plain text meant to be spoken out loud.
44
  """
 
10
  You are an expert Architecture Tour Guide.
11
  Your task is to analyze the location and provide fascinating architectural details, styles, and design elements.
12
  Write in a descriptive and technical yet accessible tone.
13
+ IMPORTANT: You MUST write the script entirely in Vietnamese.
14
  Output the script directly, without any markdown formatting or meta-commentary.
15
  """
16
 
 
18
  You are a passionate Culinary Tour Guide.
19
  Your task is to describe the iconic dishes, food culture, and local delicacies of the location.
20
  Write in an engaging, appetizing, and enthusiastic tone.
21
+ IMPORTANT: You MUST write the script entirely in Vietnamese.
22
  Output the script directly, without any markdown formatting or meta-commentary.
23
  """
24
 
 
26
  You are an enthusiastic Cultural Tour Guide.
27
  Your task is to explore and explain the local customs, traditions, and artistic heritage of the location.
28
  Write in a lively and engaging tone.
29
+ IMPORTANT: You MUST write the script entirely in Vietnamese.
30
  Output the script directly, without any markdown formatting or meta-commentary.
31
  """
32
 
 
34
  You are an authoritative Historical Tour Guide.
35
  Your task is to deliver insightful historical narratives, key events, and the backstory of the location.
36
  Write in a captivating, storytelling tone.
37
+ IMPORTANT: You MUST write the script entirely in Vietnamese.
38
  Output the script directly, without any markdown formatting or meta-commentary.
39
  """
40
 
 
44
  and weave them into a single, cohesive, and seamless audio tour script.
45
  Create a welcoming introduction, smooth transitions between topics, and a memorable conclusion.
46
  The final script should sound like a single continuous tour guide speaking.
47
+ IMPORTANT: You MUST write the final script entirely in Vietnamese.
48
  DO NOT use markdown formatting, bold text, or asterisks. Output plain text meant to be spoken out loud.
49
  """
streamlit_app.py CHANGED
@@ -22,6 +22,7 @@ def main():
22
  # Save API key to session state
23
  if api_key_input:
24
  st.session_state["api_key"] = api_key_input
 
25
 
26
  api_key = st.session_state.get("api_key") or os.environ.get("GEMINI_API_KEY")
27
 
@@ -29,7 +30,12 @@ def main():
29
 
30
  # Main content
31
  location = st.text_input("Địa danh (Location)", placeholder="Ví dụ: Hội An, Đà Lạt, Hồ Gươm...")
32
- interests = st.text_area("Chủ đề quan tâm (Interests)", placeholder="Ví dụ: Lịch sử cổ đại, ẩm thực đường phố, kiến trúc Pháp...")
 
 
 
 
 
33
  duration = st.slider("Thời lượng dự kiến (phút)", min_value=5, max_value=60, value=15, step=5)
34
 
35
  if st.button("Tạo Audio Tour", type="primary"):
@@ -53,8 +59,18 @@ def main():
53
  with open(script_file, "r", encoding="utf-8") as f:
54
  final_script = f.read()
55
  st.audio(audio_file, format="audio/mp3")
 
 
 
 
 
 
 
 
 
56
  st.markdown("### Kịch bản Tour")
57
- st.write(final_script)
 
58
  return
59
 
60
  # Not in cache, generate fresh
@@ -72,8 +88,18 @@ def main():
72
 
73
  st.success("Hoàn thành! Chúc bạn có một chuyến đi vui vẻ.")
74
  st.audio(audio_file, format="audio/mp3")
 
 
 
 
 
 
 
 
 
75
  st.markdown("### Kịch bản Tour")
76
- st.write(final_script)
 
77
  else:
78
  st.error("Có lỗi xảy ra trong quá trình tạo Audio.")
79
 
 
22
  # Save API key to session state
23
  if api_key_input:
24
  st.session_state["api_key"] = api_key_input
25
+ st.sidebar.success("Đã lưu API Key tạm thời.")
26
 
27
  api_key = st.session_state.get("api_key") or os.environ.get("GEMINI_API_KEY")
28
 
 
30
 
31
  # Main content
32
  location = st.text_input("Địa danh (Location)", placeholder="Ví dụ: Hội An, Đà Lạt, Hồ Gươm...")
33
+ interests_list = st.multiselect(
34
+ "Chủ đề quan tâm (Interests)",
35
+ options=["Lịch sử (History)", "Văn hóa (Culture)", "Ẩm thực (Culinary)", "Kiến trúc (Architecture)"],
36
+ default=["Lịch sử (History)", "Văn hóa (Culture)"]
37
+ )
38
+ interests = ", ".join(interests_list)
39
  duration = st.slider("Thời lượng dự kiến (phút)", min_value=5, max_value=60, value=15, step=5)
40
 
41
  if st.button("Tạo Audio Tour", type="primary"):
 
59
  with open(script_file, "r", encoding="utf-8") as f:
60
  final_script = f.read()
61
  st.audio(audio_file, format="audio/mp3")
62
+
63
+ with open(audio_file, "rb") as f:
64
+ st.download_button(
65
+ label="Tải file âm thanh (.mp3)",
66
+ data=f,
67
+ file_name=f"AudioTour_{location}.mp3",
68
+ mime="audio/mp3"
69
+ )
70
+
71
  st.markdown("### Kịch bản Tour")
72
+ with st.container(height=300):
73
+ st.write(final_script)
74
  return
75
 
76
  # Not in cache, generate fresh
 
88
 
89
  st.success("Hoàn thành! Chúc bạn có một chuyến đi vui vẻ.")
90
  st.audio(audio_file, format="audio/mp3")
91
+
92
+ with open(audio_file, "rb") as f:
93
+ st.download_button(
94
+ label="Tải file âm thanh (.mp3)",
95
+ data=f,
96
+ file_name=f"AudioTour_{location}.mp3",
97
+ mime="audio/mp3"
98
+ )
99
+
100
  st.markdown("### Kịch bản Tour")
101
+ with st.container(height=300):
102
+ st.write(final_script)
103
  else:
104
  st.error("Có lỗi xảy ra trong quá trình tạo Audio.")
105