Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,16 +10,16 @@ import json
|
|
| 10 |
# =========================
|
| 11 |
|
| 12 |
COUNT_VARIANTS = {
|
| 13 |
-
10: ["じゅう", "じゅーう", "じゅーーーう"],
|
| 14 |
-
9: ["きゅう", "きゅーう", "きゅーーーう"],
|
| 15 |
-
8: ["はち", "はーち", "はーーーち"],
|
| 16 |
-
7: ["なな", "なーな", "なーーーな"],
|
| 17 |
-
6: ["ろく", "ろーく", "ろーーーく"],
|
| 18 |
-
5: ["ご", "ごー", "ごーーー"],
|
| 19 |
-
4: ["よん", "よーん", "よーーーん"],
|
| 20 |
-
3: ["さん", "さーん", "さーーーん"],
|
| 21 |
-
2: ["に", "にー", "にーーー", "にい"],
|
| 22 |
-
1: ["いち", "いーち", "いーーーち"],
|
| 23 |
0: ["ぜろ", "ぜーろ", "ぜろっ", "れい"],
|
| 24 |
}
|
| 25 |
|
|
@@ -78,6 +78,10 @@ def generate_script(max_count: int) -> str:
|
|
| 78 |
interrupt_count = 0
|
| 79 |
MAX_INTERRUPTS = 10
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# 最近使ったセリフを記憶(重複回避用)
|
| 82 |
recent_interrupts = [] # 最近3つの中断セリフ
|
| 83 |
recent_reactions = [] # 最近3つのリアクション
|
|
@@ -94,7 +98,7 @@ def generate_script(max_count: int) -> str:
|
|
| 94 |
return selected
|
| 95 |
|
| 96 |
while current >= 0: # 0まで含む
|
| 97 |
-
# カウント
|
| 98 |
variant = get_count_variant(current)
|
| 99 |
script.append(variant)
|
| 100 |
|
|
@@ -102,26 +106,35 @@ def generate_script(max_count: int) -> str:
|
|
| 102 |
if current == 0:
|
| 103 |
repeat_count = random.randint(2, 4) # 2〜4回繰り返す
|
| 104 |
for _ in range(repeat_count - 1):
|
| 105 |
-
script.append("、")
|
| 106 |
script.append(get_count_variant(0))
|
| 107 |
break # 0に到達したら終了
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
# リアクション(30%の確率)
|
| 113 |
if random.random() < 0.3:
|
| 114 |
reaction = get_unique_item(REACTIONS, recent_reactions)
|
| 115 |
script.append(reaction)
|
| 116 |
-
script.append("、")
|
| 117 |
|
| 118 |
# 中断(上限チェック付き)
|
| 119 |
if interrupt_count < MAX_INTERRUPTS and random.random() < interrupt_rate(max_count):
|
| 120 |
interrupt = get_unique_item(INTERRUPTS, recent_interrupts)
|
| 121 |
script.append(interrupt)
|
| 122 |
-
script.append("。")
|
| 123 |
current = max_count
|
| 124 |
interrupt_count += 1
|
|
|
|
| 125 |
continue
|
| 126 |
|
| 127 |
current -= 1
|
|
|
|
| 10 |
# =========================
|
| 11 |
|
| 12 |
COUNT_VARIANTS = {
|
| 13 |
+
10: ["じゅう、、", "じゅーう、、、", "じゅーーーう、、、、"],
|
| 14 |
+
9: ["きゅう、、", "きゅーう、、、", "きゅーーーう、、、、"],
|
| 15 |
+
8: ["はち、、", "はーち、、、", "はーーーち、、、、"],
|
| 16 |
+
7: ["なな、、", "なーな、、、", "なーーーな、、、、"],
|
| 17 |
+
6: ["ろく、、", "ろーく、、、", "ろーーーく、、、、"],
|
| 18 |
+
5: ["ご、、", "ごー、、、", "ごーーー、、、、"],
|
| 19 |
+
4: ["よん、、", "よーん、、、", "よーーーん、、、、"],
|
| 20 |
+
3: ["さん、、", "さーん、、、", "さーーーん、、、、"],
|
| 21 |
+
2: ["に、、", "にー、、、", "にーーー、、、、", "にい、、、"],
|
| 22 |
+
1: ["いち、、", "いーち、、、", "いーーーち、、、、"],
|
| 23 |
0: ["ぜろ", "ぜーろ", "ぜろっ", "れい"],
|
| 24 |
}
|
| 25 |
|
|
|
|
| 78 |
interrupt_count = 0
|
| 79 |
MAX_INTERRUPTS = 10
|
| 80 |
|
| 81 |
+
# 最初の何カウント分は中断やリアクションを入れないか
|
| 82 |
+
initial_countdown = random.randint(3, 5)
|
| 83 |
+
counts_done = 0
|
| 84 |
+
|
| 85 |
# 最近使ったセリフを記憶(重複回避用)
|
| 86 |
recent_interrupts = [] # 最近3つの中断セリフ
|
| 87 |
recent_reactions = [] # 最近3つのリアクション
|
|
|
|
| 98 |
return selected
|
| 99 |
|
| 100 |
while current >= 0: # 0まで含む
|
| 101 |
+
# カウント(既に間を含む)
|
| 102 |
variant = get_count_variant(current)
|
| 103 |
script.append(variant)
|
| 104 |
|
|
|
|
| 106 |
if current == 0:
|
| 107 |
repeat_count = random.randint(2, 4) # 2〜4回繰り返す
|
| 108 |
for _ in range(repeat_count - 1):
|
| 109 |
+
script.append("、、、")
|
| 110 |
script.append(get_count_variant(0))
|
| 111 |
break # 0に到達したら終了
|
| 112 |
|
| 113 |
+
counts_done += 1
|
| 114 |
+
|
| 115 |
+
# 最初の数カウントは他のセリフを挟まない
|
| 116 |
+
if counts_done <= initial_countdown:
|
| 117 |
+
current -= 1
|
| 118 |
+
continue
|
| 119 |
+
|
| 120 |
+
# 追加の間(長めに)
|
| 121 |
+
if random.random() < 0.4:
|
| 122 |
+
script.append("、、、")
|
| 123 |
|
| 124 |
# リアクション(30%の確率)
|
| 125 |
if random.random() < 0.3:
|
| 126 |
reaction = get_unique_item(REACTIONS, recent_reactions)
|
| 127 |
script.append(reaction)
|
| 128 |
+
script.append("、、、、") # リアクション後は長めの間
|
| 129 |
|
| 130 |
# 中断(上限チェック付き)
|
| 131 |
if interrupt_count < MAX_INTERRUPTS and random.random() < interrupt_rate(max_count):
|
| 132 |
interrupt = get_unique_item(INTERRUPTS, recent_interrupts)
|
| 133 |
script.append(interrupt)
|
| 134 |
+
script.append("。、、、、、") # 中断後は特に長い間
|
| 135 |
current = max_count
|
| 136 |
interrupt_count += 1
|
| 137 |
+
counts_done = 0 # カウントリセット
|
| 138 |
continue
|
| 139 |
|
| 140 |
current -= 1
|