soiz1 commited on
Commit
498dde8
·
verified ·
1 Parent(s): 6586956

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -49
app.py CHANGED
@@ -352,55 +352,53 @@ def update_reference_audio(selected_image):
352
  return image_mp3_mapping[selected_image]["mp3"]
353
  return None
354
 
355
- if __name__ == "__main__":
 
356
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
357
  "参考音声が25秒を超える場合、自動的に25秒にクリップされます。"
358
  "また、元音声と参考音声の合計時間が30秒を超える場合、元音声は分割処理されます。")
359
-
360
- inputs = [
361
- gr.Audio(type="filepath", label="元音声"),
362
- gr.Audio(type="filepath", label="参考音声"),
363
- gr.Slider(minimum=1, maximum=200, value=10, step=1, label="拡散ステップ数", info="デフォルトは10、50~100が最適な品質"),
364
- gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="長さ調整", info="1.0未満で速度を上げ、1.0以上で速度を遅くします"),
365
- gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="推論CFG率", info="わずかな影響があります"),
366
- gr.Checkbox(label="F0条件付きモデルを使用", value=False, info="歌声変換には必須です"),
367
- gr.Checkbox(label="F0自動調整", value=True, info="F0をおおよそ調整して目標音声に合わせます。F0条件付きモデル使用時にのみ有効です"),
368
- gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
369
- ]
370
-
371
- # ギャラリーとして画像を表示 (画像URLを表示)
372
- image_gallery = gr.Radio(
373
- label="画像ギャラリー",
374
- choices=["sikokumetan"], # 画像のキーを選択肢として使用
375
- type="index", # 画像のインデックスを選択する形式
376
- info="画像を選択してください"
377
- )
378
-
379
- # ギャラリー選択に基づいて参考音声を更新するコンポーネント
380
- reference_audio = gr.Audio(type="filepath", label="参考音声")
381
-
382
- def update_audio(selected_image):
383
- selected_mp3 = update_reference_audio(selected_image)
384
- return selected_mp3
385
-
386
- image_gallery.change(fn=update_audio, inputs=image_gallery, outputs=reference_audio)
387
-
388
- examples = [["examples/source/yae_0.wav", "examples/reference/dingzhen_0.wav", 25, 1.0, 0.7, False, True, 0],
389
- ["examples/source/jay_0.wav", "examples/reference/azuma_0.wav", 25, 1.0, 0.7, True, True, 0],
390
- ["examples/source/Wiz Khalifa,Charlie Puth - See You Again [vocals]_[cut_28sec].wav",
391
- "examples/reference/teio_0.wav", 100, 1.0, 0.7, True, False, 0],
392
- ["examples/source/TECHNOPOLIS - 2085 [vocals]_[cut_14sec].wav",
393
- "examples/reference/trump_0.wav", 50, 1.0, 0.7, True, False, -12],
394
- ]
395
-
396
- outputs = [gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
397
- gr.Audio(label="完全出力音声", streaming=False, format='wav')]
398
-
399
- gr.Interface(fn=voice_conversion,
400
- description=description,
401
- inputs=[*inputs, image_gallery, reference_audio],
402
- outputs=outputs,
403
- title="Seed Voice Conversion",
404
- examples=examples,
405
- cache_examples=False,
406
- ).launch()
 
352
  return image_mp3_mapping[selected_image]["mp3"]
353
  return None
354
 
355
+ # Blocksコンテキストを使用してUIを作成
356
+ with gr.Blocks() as demo:
357
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
358
  "参考音声が25秒を超える場合、自動的に25秒にクリップされます。"
359
  "また、元音声と参考音声の合計時間が30秒を超える場合、元音声は分割処理されます。")
360
+
361
+ with gr.Column():
362
+ inputs = [
363
+ gr.Audio(type="filepath", label="元音声"),
364
+ gr.Audio(type="filepath", label="参考音声"),
365
+ gr.Slider(minimum=1, maximum=200, value=10, step=1, label="拡散ステップ数", info="デフォルトは10、50~100が最適な品質"),
366
+ gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="長さ調整", info="1.0未満で速度を上げ、1.0以上で速度を遅くします"),
367
+ gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="推論CFG率", info="わずかな影響があります"),
368
+ gr.Checkbox(label="F0条件付きモデルを使用", value=False, info="歌声変換には必須です"),
369
+ gr.Checkbox(label="F0自動調整", value=True, info="F0をおおよそ調整して目標音声に合わせます。F0条件付きモデル使用時にのみ有効です"),
370
+ gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
371
+ ]
372
+
373
+ # ギャラリーとして画像を表示 (画像URLを表示)
374
+ image_gallery = gr.Radio(
375
+ label="画像ギャラリー",
376
+ choices=["sikokumetan"], # 画像のキーを選択肢として使用
377
+ type="index", # 画像のインデックスを選択する形式
378
+ info="画像を選択してください"
379
+ )
380
+
381
+ # ギャラリー選択に基づいて参考音声を更新するコンポーネント
382
+ reference_audio = gr.Audio(type="filepath", label="参考音声")
383
+
384
+ # ギャラリー選択に基づいて参考音声を更新する関数
385
+ def update_audio(selected_image):
386
+ selected_mp3 = update_reference_audio(selected_image)
387
+ return selected_mp3
388
+
389
+ # 画像選択の変更イベントに反応
390
+ image_gallery.change(fn=update_audio, inputs=image_gallery, outputs=reference_audio)
391
+
392
+ examples = [["examples/source/yae_0.wav", "examples/reference/dingzhen_0.wav", 25, 1.0, 0.7, False, True, 0],
393
+ ["examples/source/jay_0.wav", "examples/reference/azuma_0.wav", 25, 1.0, 0.7, True, True, 0],
394
+ ["examples/source/Wiz Khalifa,Charlie Puth - See You Again [vocals]_[cut_28sec].wav",
395
+ "examples/reference/teio_0.wav", 100, 1.0, 0.7, True, False, 0],
396
+ ["examples/source/TECHNOPOLIS - 2085 [vocals]_[cut_14sec].wav",
397
+ "examples/reference/trump_0.wav", 50, 1.0, 0.7, True, False, -12],
398
+ ]
399
+
400
+ outputs = [gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
401
+ gr.Audio(label="完全出力音声", streaming=False, format='wav')]
402
+
403
+ # インターフェースを起動
404
+ demo.launch()