Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,6 +22,11 @@ TEMPLATES = {
|
|
| 22 |
EFFECTS = ["なし", "ふわふわ化", "かちかち化", "減衰", "リバーブ", "音揺れ"]
|
| 23 |
|
| 24 |
def generate_tts(text, template_name, pitch_factor=1.0, speed_factor=1.0, effect_type="なし", effect_strength=1.0):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# 音声合成(Gtts使用)
|
| 26 |
tts = gTTS(text=text, lang='ja')
|
| 27 |
|
|
@@ -36,7 +41,7 @@ def generate_tts(text, template_name, pitch_factor=1.0, speed_factor=1.0, effect
|
|
| 36 |
sound = change_pitch(sound, pitch_factor)
|
| 37 |
|
| 38 |
# 速度変更
|
| 39 |
-
sound = change_speed(sound,
|
| 40 |
|
| 41 |
# エフェクト適用
|
| 42 |
sound = apply_effect(sound, effect_type, effect_strength)
|
|
@@ -74,12 +79,12 @@ def apply_effect(sound, effect_type, effect_strength):
|
|
| 74 |
return sound
|
| 75 |
|
| 76 |
def wobble(sound, strength):
|
| 77 |
-
# 0.
|
| 78 |
-
chunk_ms =
|
| 79 |
chunks = [sound[i:i+chunk_ms] for i in range(0, len(sound), chunk_ms)]
|
| 80 |
wobbled = AudioSegment.empty()
|
| 81 |
for chunk in chunks:
|
| 82 |
-
pitch_shift = np.random.uniform(1 - 0.
|
| 83 |
chunk = change_pitch(chunk, pitch_shift)
|
| 84 |
wobbled += chunk
|
| 85 |
return wobbled
|
|
|
|
| 22 |
EFFECTS = ["なし", "ふわふわ化", "かちかち化", "減衰", "リバーブ", "音揺れ"]
|
| 23 |
|
| 24 |
def generate_tts(text, template_name, pitch_factor=1.0, speed_factor=1.0, effect_type="なし", effect_strength=1.0):
|
| 25 |
+
# テンプレートの設定を反映
|
| 26 |
+
template = TEMPLATES.get(template_name, {"rate": 150, "volume": 1.0})
|
| 27 |
+
rate = template["rate"] * speed_factor # 速度調整
|
| 28 |
+
volume = template["volume"] # ボリューム調整
|
| 29 |
+
|
| 30 |
# 音声合成(Gtts使用)
|
| 31 |
tts = gTTS(text=text, lang='ja')
|
| 32 |
|
|
|
|
| 41 |
sound = change_pitch(sound, pitch_factor)
|
| 42 |
|
| 43 |
# 速度変更
|
| 44 |
+
sound = change_speed(sound, rate / 100) # 速度が「%」であることを考慮
|
| 45 |
|
| 46 |
# エフェクト適用
|
| 47 |
sound = apply_effect(sound, effect_type, effect_strength)
|
|
|
|
| 79 |
return sound
|
| 80 |
|
| 81 |
def wobble(sound, strength):
|
| 82 |
+
# 0.1秒ごとにランダムにピッチを揺らす(揺れを強くする)
|
| 83 |
+
chunk_ms = 100
|
| 84 |
chunks = [sound[i:i+chunk_ms] for i in range(0, len(sound), chunk_ms)]
|
| 85 |
wobbled = AudioSegment.empty()
|
| 86 |
for chunk in chunks:
|
| 87 |
+
pitch_shift = np.random.uniform(1 - 0.05 * strength, 1 + 0.05 * strength) # 強めの揺れ
|
| 88 |
chunk = change_pitch(chunk, pitch_shift)
|
| 89 |
wobbled += chunk
|
| 90 |
return wobbled
|