soiz1 commited on
Commit
cfa9320
·
verified ·
1 Parent(s): c9fdce1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -35
app.py CHANGED
@@ -337,26 +337,15 @@ def voice_conversion(source, target, diffusion_steps, length_adjust, inference_c
337
  yield mp3_bytes, None
338
 
339
 
340
- examples = [["examples/source/yae_0.wav", "examples/reference/dingzhen_0.wav", 25, 1.0, 0.7, False, True, 0],
341
- ["examples/source/jay_0.wav", "examples/reference/azuma_0.wav", 25, 1.0, 0.7, True, True, 0],
342
- ["examples/source/Wiz Khalifa,Charlie Puth - See You Again [vocals]_[cut_28sec].wav",
343
- "examples/reference/teio_0.wav", 100, 1.0, 0.7, True, False, 0],
344
- ["examples/source/TECHNOPOLIS - 2085 [vocals]_[cut_14sec].wav",
345
- "examples/reference/trump_0.wav", 50, 1.0, 0.7, True, False, -12],
346
- ]
347
-
348
- # 画像とMP3ファイルの情報
349
- gallery_items = [
350
- {"image": "default/sikokumetan.webp", "mp3": "default/sikokumetan.mp3"}
351
  ]
352
 
353
- # 画像をクリックした時に呼び出す関数
354
- def set_reference_audio(image_path):
355
- # ギャラリーの画像に対応するMP3ファイルを返す
356
- for item in gallery_items:
357
- if item["image"] == image_path:
358
  return item["mp3"]
359
- return None
360
 
361
  if __name__ == "__main__":
362
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
@@ -366,29 +355,25 @@ if __name__ == "__main__":
366
  inputs = [
367
  gr.Audio(type="filepath", label="元音声"),
368
  gr.Audio(type="filepath", label="参考音声"),
 
 
369
  gr.Slider(minimum=1, maximum=200, value=10, step=1, label="拡散ステップ数", info="デフォルトは10、50~100が最適な品質"),
370
  gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="長さ調整", info="1.0未満で速度を上げ、1.0以上で速度を遅くします"),
371
  gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="推論CFG率", info="わずかな影響があります"),
372
  gr.Checkbox(label="F0条件付きモデルを使用", value=False, info="歌声変換には必須です"),
373
  gr.Checkbox(label="F0自動調整", value=True, info="F0をおおよそ調整して目標音声に合わせます。F0条件付きモデル使用時にのみ有効です"),
374
  gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
375
- gr.Gallery(value=[item["image"] for item in gallery_items], label="画像ギャラリー", interactive=True)
376
  ]
377
 
378
- def update_reference_audio(selected_image):
379
- # ギャラリーで選択された画像に対応するMP3ファイルを返す
380
- mp3_file = set_reference_audio(selected_image)
381
- return mp3_file
382
-
383
- # ギャラリーで選択された画像を参考音声の入力に反映
384
- gr.Interface(
385
- fn=voice_conversion,
386
- description=description,
387
- inputs=inputs,
388
- outputs=[gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
389
- gr.Audio(label="完全出力音声", streaming=False, format='wav')],
390
- title="Seed Voice Conversion",
391
- examples=examples,
392
- cache_examples=False,
393
- live=True
394
- ).launch()
 
337
  yield mp3_bytes, None
338
 
339
 
340
+ gallery_data = [
341
+ {"name": "sikokumetan", "webp": "default/sikokumetan.webp", "mp3": "default/sikokumetan.mp3"}
 
 
 
 
 
 
 
 
 
342
  ]
343
 
344
+ def auto_set_reference(selected_image):
345
+ for item in gallery_data:
346
+ if item["webp"] == selected_image:
 
 
347
  return item["mp3"]
348
+ return ""
349
 
350
  if __name__ == "__main__":
351
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
 
355
  inputs = [
356
  gr.Audio(type="filepath", label="元音声"),
357
  gr.Audio(type="filepath", label="参考音声"),
358
+ gr.Gallery(label="ギャラリー", value=[item["webp"] for item in gallery_data],
359
+ interactive=True, elem_id="gallery"),
360
  gr.Slider(minimum=1, maximum=200, value=10, step=1, label="拡散ステップ数", info="デフォルトは10、50~100が最適な品質"),
361
  gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label="長さ調整", info="1.0未満で速度を上げ、1.0以上で速度を遅くします"),
362
  gr.Slider(minimum=0.0, maximum=1.0, step=0.1, value=0.7, label="推論CFG率", info="わずかな影響があります"),
363
  gr.Checkbox(label="F0条件付きモデルを使用", value=False, info="歌声変換には必須です"),
364
  gr.Checkbox(label="F0自動調整", value=True, info="F0をおおよそ調整して目標音声に合わせます。F0条件付きモデル使用時にのみ有効です"),
365
  gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
 
366
  ]
367
 
368
+ outputs = [
369
+ gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
370
+ gr.Audio(label="完全出力音声", streaming=False, format='wav')
371
+ ]
372
+
373
+ gr.Interface(fn=voice_conversion,
374
+ description=description,
375
+ inputs=inputs,
376
+ outputs=outputs,
377
+ title="Seed Voice Conversion",
378
+ cache_examples=False,
379
+ ).launch()