fdbw commited on
Commit
2428438
·
verified ·
1 Parent(s): 7d79ba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -3,11 +3,9 @@ import requests
3
  from gradio_client import Client, handle_file
4
 
5
  # 本版本完全不依赖任何付费 API / 密钥,全部使用免费资源:
6
- # - 语音识别:调用免费的公共 Whisper Space(中英法都支持,统一用它,不用区分引擎)
7
  # - 翻译:调用 MyMemory 免费翻译接口
8
 
9
- # 如果调用报错,去这个地址查真实的 api_name/参数顺序,再调整 transcribe() 函数:
10
- # https://huggingface.co/spaces/hf-audio/whisper-large-v3?view=api
11
  FREE_WHISPER_SPACE = "hf-audio/whisper-large-v3"
12
  _whisper_client = None
13
 
@@ -31,10 +29,11 @@ LANG_MAP = {
31
 
32
  def transcribe(audio_path):
33
  client = get_whisper_client()
 
34
  result = client.predict(
35
- handle_file(audio_path),
36
- "transcribe",
37
- api_name="/predict",
38
  )
39
  if isinstance(result, (list, tuple)):
40
  result = result[0]
 
3
  from gradio_client import Client, handle_file
4
 
5
  # 本版本完全不依赖任何付费 API / 密钥,全部使用免费资源:
6
+ # - 语音识别:调用免费的公共 Whisper Space(中英法都支持)
7
  # - 翻译:调用 MyMemory 免费翻译接口
8
 
 
 
9
  FREE_WHISPER_SPACE = "hf-audio/whisper-large-v3"
10
  _whisper_client = None
11
 
 
29
 
30
  def transcribe(audio_path):
31
  client = get_whisper_client()
32
+ # 已修正:使用最新的 /predict_1 API 名称以及对应的形参 inputs 和 task
33
  result = client.predict(
34
+ inputs=handle_file(audio_path),
35
+ task="transcribe",
36
+ api_name="/predict_1",
37
  )
38
  if isinstance(result, (list, tuple)):
39
  result = result[0]