Skip to content

Commit

Permalink
ASR FC bad case兜底 (#208)
Browse files Browse the repository at this point in the history
* 植物识别fc bad case工程兜底

* 植物识别, 动物识别, 图像内容理解 fc bad case工程兜底

* 音频识别 fc bad case 兜底

* 音频识别 fc bad case 兜底

* 音频识别 fc bad case 兜底
  • Loading branch information
hermitgreen authored Mar 20, 2024
1 parent b906dae commit 9728dfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions appbuilder/core/components/asr/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import proto
import requests
from urllib.parse import urlparse

from appbuilder.core import utils
from appbuilder.core.component import Component
Expand Down Expand Up @@ -180,9 +181,9 @@ def tool_eval(self, name: str, streaming: bool, **kwargs):
file_url = file_urls.get(file_name, None)
if not file_url:
raise InvalidRequestArgumentError(f"file {file_url} url does not exist")
file_type = kwargs.get("file_type", "wav")
if file_type not in ["pcm", "wav", "amr", "m4a"]:
file_type = "wav"

_, file_type = os.path.splitext(os.path.basename(urlparse(file_url).path))

req = ShortSpeechRecognitionRequest()
req.speech = requests.get(file_url).content
req.format = file_type
Expand Down
2 changes: 1 addition & 1 deletion appbuilder/core/components/object_recognize/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def tool_eval(self, name: str, streaming: bool, **kwargs):
if item["score"] < score_threshold and len(results) > 0:
continue
res = {
"物品名称": item["keyword"],
"物体或场景名称": item["keyword"],
"置信度": item["score"],
"所属类别": item["root"],
}
Expand Down

0 comments on commit 9728dfa

Please sign in to comment.