Spaces:
Paused
Paused
Upload app.py
Browse files
app.py
CHANGED
|
@@ -229,8 +229,10 @@ def extract_audio_text_v2(slide: dict, slide_index: int, history: list) -> str:
|
|
| 229 |
history_index = (slide_index - 1) // 2
|
| 230 |
event = history[history_index]
|
| 231 |
year = str(event.get("year", ""))
|
|
|
|
|
|
|
| 232 |
mnemonic = clean_mnemonic(str(event.get("mnemonic", "")))
|
| 233 |
-
return f"{
|
| 234 |
|
| 235 |
elif slide_type == "imageText_with_text":
|
| 236 |
# slide_index 2, 4, 6, 8, 10, 12 → history[0, 1, 2, 3, 4, 5]
|
|
@@ -283,14 +285,14 @@ def generate_audio_with_gemini(audio_text: str, gemini_token: str) -> bytes:
|
|
| 283 |
"""
|
| 284 |
import base64
|
| 285 |
|
| 286 |
-
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-
|
| 287 |
|
| 288 |
headers = {
|
| 289 |
"Content-Type": "application/json"
|
| 290 |
}
|
| 291 |
|
| 292 |
-
# プロンプトベース制御(
|
| 293 |
-
prompt_text = f"
|
| 294 |
|
| 295 |
payload = {
|
| 296 |
"contents": [
|
|
|
|
| 229 |
history_index = (slide_index - 1) // 2
|
| 230 |
event = history[history_index]
|
| 231 |
year = str(event.get("year", ""))
|
| 232 |
+
# 既に「年」が含まれている場合は除去(重複防止)
|
| 233 |
+
year_clean = year.replace("年", "")
|
| 234 |
mnemonic = clean_mnemonic(str(event.get("mnemonic", "")))
|
| 235 |
+
return f"{year_clean}年、{mnemonic}。{year_clean}年、{mnemonic}。"
|
| 236 |
|
| 237 |
elif slide_type == "imageText_with_text":
|
| 238 |
# slide_index 2, 4, 6, 8, 10, 12 → history[0, 1, 2, 3, 4, 5]
|
|
|
|
| 285 |
"""
|
| 286 |
import base64
|
| 287 |
|
| 288 |
+
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-preview-tts:generateContent?key={gemini_token}"
|
| 289 |
|
| 290 |
headers = {
|
| 291 |
"Content-Type": "application/json"
|
| 292 |
}
|
| 293 |
|
| 294 |
+
# プロンプトベース制御(歴史用語の正確な読み上げを重視)
|
| 295 |
+
prompt_text = f"Pronounce this Japanese text correctly, paying careful attention to historical vocabulary and proper kanji readings: {audio_text}"
|
| 296 |
|
| 297 |
payload = {
|
| 298 |
"contents": [
|