GPTfree api commited on
Commit
fa51e11
·
verified ·
1 Parent(s): 709fe05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -12,13 +12,6 @@ if HF_TOKEN is None:
12
  # クライアント設定
13
  client = Client("Plachta/Seed-VC", hf_token=HF_TOKEN)
14
 
15
- # handle_file関数をトークン認証付きに拡張
16
- def handle_file_with_auth(file_path: str) -> dict:
17
- headers = {"Authorization": f"Bearer {HF_TOKEN}"}
18
- # ファイルパスをログ出力
19
- print(f"Handling file with authentication: {file_path}")
20
- return {"name": os.path.basename(file_path), "data": file_path, "headers": headers}
21
-
22
  def process_audio(
23
  source,
24
  target,
@@ -33,7 +26,7 @@ def process_audio(
33
  # ファイルパスをログ出力
34
  print(f"Source file: {source}")
35
  print(f"Target file: {target}")
36
-
37
  # APIリクエスト時のパラメータをログ出力
38
  print(f"Parameters: diffusion_steps={diffusion_steps}, length_adjust={length_adjust}, "
39
  f"inference_cfg_rate={inference_cfg_rate}, f0_condition={f0_condition}, "
@@ -41,8 +34,8 @@ def process_audio(
41
 
42
  # API呼び出し
43
  result = client.predict(
44
- source=handle_file_with_auth(source),
45
- target=handle_file_with_auth(target),
46
  diffusion_steps=diffusion_steps,
47
  length_adjust=length_adjust,
48
  inference_cfg_rate=inference_cfg_rate,
@@ -51,10 +44,18 @@ def process_audio(
51
  pitch_shift=pitch_shift,
52
  api_name="/predict"
53
  )
54
-
55
- # 結果のログ出力
56
- print(f"Result: {result}")
57
-
 
 
 
 
 
 
 
 
58
  return result # 成功時は結果をそのまま返す
59
 
60
  except Exception as e:
 
12
  # クライアント設定
13
  client = Client("Plachta/Seed-VC", hf_token=HF_TOKEN)
14
 
 
 
 
 
 
 
 
15
  def process_audio(
16
  source,
17
  target,
 
26
  # ファイルパスをログ出力
27
  print(f"Source file: {source}")
28
  print(f"Target file: {target}")
29
+
30
  # APIリクエスト時のパラメータをログ出力
31
  print(f"Parameters: diffusion_steps={diffusion_steps}, length_adjust={length_adjust}, "
32
  f"inference_cfg_rate={inference_cfg_rate}, f0_condition={f0_condition}, "
 
34
 
35
  # API呼び出し
36
  result = client.predict(
37
+ source=handle_file(source),
38
+ target=handle_file(target),
39
  diffusion_steps=diffusion_steps,
40
  length_adjust=length_adjust,
41
  inference_cfg_rate=inference_cfg_rate,
 
44
  pitch_shift=pitch_shift,
45
  api_name="/predict"
46
  )
47
+
48
+ # レスポンスのログ出力
49
+ print(f"API Response: {result}")
50
+
51
+ # レスポンス内にトークンが含まれているか確認
52
+ if isinstance(result, tuple) and len(result) > 1:
53
+ stream_audio_url, full_audio_url = result
54
+ print(f"Stream Output URL: {stream_audio_url}")
55
+ print(f"Full Output URL: {full_audio_url}")
56
+ else:
57
+ print("Unexpected response format.")
58
+
59
  return result # 成功時は結果をそのまま返す
60
 
61
  except Exception as e: