soiz1 commited on
Commit
a1bbd98
·
verified ·
1 Parent(s): 3310f9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -42
app.py CHANGED
@@ -733,36 +733,21 @@ if __name__ == "__main__":
733
  ).launch()
734
 
735
 
736
-
737
-
738
  import gradio as gr
739
 
740
- # ギャラリーの画像と対応するMP3ファイル
741
- gallery_data = [
742
- {
743
- "image": "default/sikokumetan.webp",
744
- "mp3": "default/sikokumetan.mp3"
745
- }
746
- ]
747
 
748
- # ギャラリーの画像が選択された際の処理
749
- def on_image_select(image_path):
750
- for item in gallery_data:
751
- if item["image"] == image_path:
752
- return item["mp3"]
753
- return None
754
-
755
- # 出力の再定義 (重要)
756
- outputs = [
757
- gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
758
- gr.Audio(label="完全出力音声", streaming=False, format='wav')
759
- ]
760
 
761
  if __name__ == "__main__":
762
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
763
  "参考音声が25秒を超える場合、自動的に25秒にクリップされます。"
764
  "また、元音声と参考音声の合計時間が30秒を超える場合、元音声は分割処理されます。")
765
-
766
  inputs = [
767
  gr.Audio(type="filepath", label="元音声"),
768
  gr.Audio(type="filepath", label="参考音声"),
@@ -774,25 +759,24 @@ if __name__ == "__main__":
774
  gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
775
  ]
776
 
777
- # ギャラリーコンポーネントの追加
778
- gallery = gr.Gallery(
779
- value=[item["image"] for item in gallery_data],
780
- label="参考音声選択画像",
781
- interactive=True,
782
- columns=3
783
- )
784
 
785
- # ギャラリー画像が選択されたときにMP3を自動で設定
786
- def update_reference_audio(selected_image):
787
- return on_image_select(selected_image)
788
 
789
- # 参考音声を選択するためのインターフェースを更新
790
- gr.Interface(
791
- fn=voice_conversion,
792
- description=description,
793
- inputs=[*inputs, gallery],
794
- outputs=outputs, # ここでoutputsを正しく指定
795
- title="Seed Voice Conversion",
796
- examples=examples,
797
- cache_examples=False,
798
- ).launch()
 
733
  ).launch()
734
 
735
 
 
 
736
  import gradio as gr
737
 
738
+ gallery_data = {"sikokumetan": {"webp": "default/sikokumetan.webp", "mp3": "default/sikokumetan.mp3"}}
 
 
 
 
 
 
739
 
740
+ def update_reference(selected_image):
741
+ for key, value in gallery_data.items():
742
+ if value["webp"] == selected_image:
743
+ return value["mp3"]
744
+ return ""
 
 
 
 
 
 
 
745
 
746
  if __name__ == "__main__":
747
  description = ("Zero-shot音声変換モデル(学習不要)。ローカルでの利用方法は[GitHubリポジトリ](https://github.com/Plachtaa/seed-vc)をご覧ください。"
748
  "参考音声が25秒を超える場合、自動的に25秒にクリップされます。"
749
  "また、元音声と参考音声の合計時間が30秒を超える場合、元音声は分割処理されます。")
750
+
751
  inputs = [
752
  gr.Audio(type="filepath", label="元音声"),
753
  gr.Audio(type="filepath", label="参考音声"),
 
759
  gr.Slider(label='音程変換', minimum=-24, maximum=24, step=1, value=0, info="半音単位の音程変換。F0条件付きモデル使用時にのみ有効です"),
760
  ]
761
 
762
+ examples = [["examples/source/yae_0.wav", "examples/reference/dingzhen_0.wav", 25, 1.0, 0.7, False, True, 0],
763
+ ["examples/source/jay_0.wav", "examples/reference/azuma_0.wav", 25, 1.0, 0.7, True, True, 0],
764
+ ["examples/source/Wiz Khalifa,Charlie Puth - See You Again [vocals]_[cut_28sec].wav",
765
+ "examples/reference/teio_0.wav", 100, 1.0, 0.7, True, False, 0],
766
+ ["examples/source/TECHNOPOLIS - 2085 [vocals]_[cut_14sec].wav",
767
+ "examples/reference/trump_0.wav", 50, 1.0, 0.7, True, False, -12],
768
+ ]
769
 
770
+ outputs = [gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
771
+ gr.Audio(label="完全出力音声", streaming=False, format='wav')]
 
772
 
773
+ with gr.Blocks() as interface:
774
+ gr.Interface(fn=voice_conversion, description=description, inputs=inputs, outputs=outputs, title="Seed Voice Conversion", examples=examples, cache_examples=False)
775
+
776
+ with gr.Row():
777
+ gallery = gr.Gallery(label="ギャラリー", show_label=True)
778
+ gallery.add([gallery_data["sikokumetan"]["webp"]])
779
+
780
+ gallery.select(update_reference, outputs=inputs[1])
781
+
782
+ interface.launch()