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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -731,6 +731,10 @@ if __name__ == "__main__":
731
  examples=examples,
732
  cache_examples=False,
733
  ).launch()
 
 
 
 
734
  import gradio as gr
735
 
736
  # ギャラリーの画像と対応するMP3ファイル
@@ -743,13 +747,12 @@ gallery_data = [
743
 
744
  # ギャラリーの画像が選択された際の処理
745
  def on_image_select(image_path):
746
- # 画像に対応するMP3を取得
747
  for item in gallery_data:
748
  if item["image"] == image_path:
749
  return item["mp3"]
750
  return None
751
 
752
- # 出力定義
753
  outputs = [
754
  gr.Audio(label="ストリーム出力音声", streaming=True, format='mp3'),
755
  gr.Audio(label="完全出力音声", streaming=False, format='wav')
@@ -773,23 +776,22 @@ if __name__ == "__main__":
773
 
774
  # ギャラリーコンポーネントの追加
775
  gallery = gr.Gallery(
776
- value=[item["image"] for item in gallery_data], # ギャラリーに表示する画像を指定
777
  label="参考音声選択画像",
778
  interactive=True,
779
- columns=3 # 3列で表示
780
  )
781
 
782
  # ギャラリー画像が選択されたときにMP3を自動で設定
783
  def update_reference_audio(selected_image):
784
- mp3_path = on_image_select(selected_image)
785
- return mp3_path
786
 
787
  # 参考音声を選択するためのインターフェースを更新
788
  gr.Interface(
789
  fn=voice_conversion,
790
  description=description,
791
- inputs=[*inputs, gallery], # ギャラリーを追加
792
- outputs=outputs, # 定義したoutputsを追加
793
  title="Seed Voice Conversion",
794
  examples=examples,
795
  cache_examples=False,
 
731
  examples=examples,
732
  cache_examples=False,
733
  ).launch()
734
+
735
+
736
+
737
+
738
  import gradio as gr
739
 
740
  # ギャラリーの画像と対応するMP3ファイル
 
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')
 
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,