File size: 9,573 Bytes
99df98c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""
FINAL COMPREHENSIVE EXPERIMENT β€” Everything Claude knows, all at once.

Learnings applied:
  - Seed 100: best contour for most segments
  - Seed 42: best for seg_004 (EXCELLENT DTW), good for seg_002
  - temp calibration: 1.0-1.15 for std<50, 1.8-1.95 for std>60, 2.0 for std>70
  - top_p=0.7, top_k=15: tightest contour control
  - top_p=0.75, top_k=20: balanced (default)
  - tokens = duration * 12.5: perfect duration match
  - IPA lengthening (e): works on specific content words in longer sentences
  - Cross-reference: longer clips (seg_003/005) give better voice clone
  - ? mark: creates rising intonation, helped seg_005
  - ... pauses: help rhythm on long sentences
  - Continuation mode: FAILS for JP->EN
  - Full IPA: HURTS β€” model handles full phoneme input differently
  - CAPS: mild effect, not reliable
  - rep_penalty: no significant effect
  - Wider top_p/top_k: more std but worse contour (tradeoff)

Strategy: For each segment, run a grid of the most promising combinations.
"""
import requests, json, time, sys

BASE = "https://yellow-yaks-matter.loca.lt"

def gen(seg_id, attempt, text, temp=1.7, top_p=0.8, top_k=25, rep=1.0,
        tokens=None, seed=42, ref_seg=None):
    payload = {
        "seg_id": seg_id, "attempt": attempt, "text": text,
        "audio_temperature": temp, "audio_top_p": top_p, "audio_top_k": top_k,
        "audio_repetition_penalty": rep, "seed": seed, "mode": "generation",
    }
    if tokens: payload["tokens"] = tokens
    if ref_seg: payload["ref_seg_id"] = ref_seg
    try:
        r = requests.post(f"{BASE}/generate", json=payload, timeout=180)
        result = r.json()
        if "error" in result:
            return None
        s = result["score"]
        f = result["f0_dtw"]
        print(f"  {seg_id}-{attempt:03d} | {s:>5.1f} | DTW={f:.3f}({result['f0_dtw_rating']:>9s}) | "
              f"F0={result['generated']['f0_mean']:.0f} std={result['generated']['f0_std']:.0f} | "
              f"t={temp} p={top_p} k={top_k} s={seed}")
        return result
    except Exception as e:
        print(f"  {seg_id}-{attempt:03d} | FAIL: {str(e)[:40]}")
        return None

requests.get(f"{BASE}/health", timeout=10)
print("="*80)
print("FINAL COMPREHENSIVE EXPERIMENT")
print("="*80)

att_counter = {1: 100, 2: 100, 3: 100, 4: 100, 5: 100}  # start from attempt 100

def next_att(sid):
    att_counter[sid] += 1
    return att_counter[sid]

# ═══════════════════════════════════════════════════════════════════
# seg_001: F0=264, std=46 (calm). Best=22.9
# Known best: temp=1.1, seed=100, ref=seg_003, IPA /everyone/
# Grid: temp[1.0, 1.05, 1.1, 1.15, 1.2] x seed[42, 77, 100] x ref[1,3]
# Plus IPA variants
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*40)
print("seg_001 β€” COMPREHENSIVE GRID (target: F0=264, std=46)")
print("="*40)

texts_1 = [
    ("plain", "Hello everyone. Thank you all, for, joining us today."),
    ("ipa_everyone", "Hello /\u025bv\u0279iw\u028c\u02d0n/. Thank you all, for, joining us today."),
    ("ipa_both", "Hello /\u025bv\u0279iw\u028c\u02d0n/. Thank you all, for, joining us /t\u0259de\u026a\u02d0/."),
]

for tname, text in texts_1:
    for temp in [1.0, 1.08, 1.15]:
        for seed in [42, 100]:
            for ref in [1, 3]:
                a = next_att(1)
                gen(1, a, text, temp=temp, top_p=0.7, top_k=15, tokens=41, seed=seed, ref_seg=ref)
                time.sleep(1.5)

# ═══════════════════════════════════════════════════════════════════
# seg_002: F0=235, std=70 (most expressive). Best=25.9
# Hardest segment. Problem: can't get high std + good contour.
# Grid: temp[1.6, 1.7, 1.8, 1.9] x seed[42, 77, 100, 123] x text variants
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*40)
print("seg_002 β€” COMPREHENSIVE GRID (target: F0=235, std=70)")
print("="*40)

texts_2 = [
    ("plain", "I'm SUEYOSHI, from the Innovation Center."),
    ("dramatic", "I'm... SUEYOSHI! From the Innovation Center."),
    ("ipa_name", "I'm /su\u02d0e\u026ajo\u028a\u0283i\u02d0/, from the Innovation Center."),
]

for tname, text in texts_2:
    for temp in [1.7, 1.8, 1.9]:
        for seed in [42, 77, 100]:
            a = next_att(2)
            gen(2, a, text, temp=temp, top_p=0.75, top_k=20, tokens=25, seed=seed)
            time.sleep(1.5)

# Also try with different refs
for seed in [42, 100]:
    for ref in [4, 5]:
        a = next_att(2)
        gen(2, a, "I'm SUEYOSHI, from the Innovation Center.",
            temp=1.8, top_p=0.75, top_k=20, tokens=25, seed=seed, ref_seg=ref)
        time.sleep(1.5)

# ═══════════════════════════════════════════════════════════════════
# seg_003: F0=240, std=67. Best=20.8
# Already good with multi-IPA. Fine-tune around sweet spot.
# Grid: temp[1.85, 1.88, 1.9, 1.92, 1.95] x seed[42, 100] x IPA variants
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*40)
print("seg_003 β€” FINE-TUNE GRID (target: F0=240, std=67)")
print("="*40)

texts_3 = [
    ("ipa_2", "For this /s\u025b\u02d0\u0283\u0259n/... please feel free to relax, and listen to the talk, while enjoying your /l\u028c\u02d0nt\u0283/."),
    ("ipa_4", "For this /s\u025b\u02d0\u0283\u0259n/... please feel /f\u0279i\u02d0/ to /\u0279\u026a\u02d0l\u00e6ks/, and listen to the talk, while enjoying your /l\u028c\u02d0nt\u0283/."),
]

for tname, text in texts_3:
    for temp in [1.87, 1.9, 1.93]:
        for seed in [42, 100]:
            a = next_att(3)
            gen(3, a, text, temp=temp, top_p=0.75, top_k=20, tokens=62, seed=seed)
            time.sleep(1.5)

# ═══════════════════════════════════════════════════════════════════
# seg_004: F0=283, std=75. Best=19.8 (EXCELLENT!)
# Already excellent. Grid around winner: temp[1.85-1.95] x seed[42] x top_p/k
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*40)
print("seg_004 β€” SQUEEZE MORE (target: F0=283, std=75)")
print("="*40)

for temp in [1.85, 1.88, 1.9, 1.92, 1.95]:
    for seed in [42, 100]:
        a = next_att(4)
        gen(4, a, "Before we begin,", temp=temp, top_p=0.75, top_k=20, tokens=21, seed=seed)
        time.sleep(1.5)

# Tighter sampling with best temp
for top_p, top_k in [(0.7, 15), (0.72, 18)]:
    a = next_att(4)
    gen(4, a, "Before we begin,", temp=1.9, top_p=top_p, top_k=top_k, tokens=21, seed=42)
    time.sleep(1.5)

# ═══════════════════════════════════════════════════════════════════
# seg_005: F0=243, std=60. Best=19.9 (EXCELLENT!)
# Grid: temp[1.82-1.88] x seed[42, 100] x text[? and plain]
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*40)
print("seg_005 β€” SQUEEZE MORE (target: F0=243, std=60)")
print("="*40)

for temp in [1.82, 1.84, 1.85, 1.86, 1.88]:
    for seed in [42, 100]:
        a = next_att(5)
        gen(5, a, "I'd like to ask, how familiar everyone here is with the Innovation Center?",
            temp=temp, top_p=0.75, top_k=20, tokens=63, seed=seed)
        time.sleep(1.5)

# IPA + ? combo
for seed in [42, 100]:
    a = next_att(5)
    gen(5, a, "I'd like to ask, how familiar everyone here is with the /\u026an\u0259ve\u026a\u02d0\u0283\u0259n s\u025bnt\u025a/?",
        temp=1.85, top_p=0.75, top_k=20, tokens=63, seed=seed)
    time.sleep(1.5)

# ═══════════════════════════════════════════════════════════════════
# FINAL RESULTS
# ═══════════════════════════════════════════════════════════════════
print("\n" + "="*80)
print("FINAL RESULTS β€” ALL EXPERIMENTS")
print("="*80)

try:
    results = requests.get(f"{BASE}/results", timeout=30).json()
    for item in results:
        print(f"  seg_{item['seg_id']:03d}: {item['total_attempts']:>3d} attempts | "
              f"best={item['best_score']:.1f} (#{item['best_attempt']}, "
              f"F0 DTW={item['best_f0_dtw']:.3f})")
    print(f"\n  Total attempts: {sum(r['total_attempts'] for r in results)}")
except Exception as e:
    print(f"  {e}")