Skip to content

Commit

Permalink
BML-APP-9343 [任务]functioncall ASR增加file_type参数&translate增加日韩法德语言
Browse files Browse the repository at this point in the history
  • Loading branch information
longchao1916 committed Mar 19, 2024
1 parent 7ff4698 commit b711231
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions appbuilder/core/components/asr/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class ASR(Component):
"file_name": {
"type": "string",
"description": "待识别语音文件名,用于生成获取语音的url"
},
"file_type": {
"type": "string",
"description": "语音文件类型,支持pcm/wav/amr/m4a",
"enum": ["pcm", "wav", "amr", "m4a"]
}
},
"anyOf": [
Expand Down Expand Up @@ -139,7 +144,7 @@ def _recognize(self, request: ShortSpeechRecognitionRequest, timeout: float = No
data = response.json()
self.http_client.check_response_json(data)
request_id = self.http_client.response_request_id(response)
self.__class__._check_service_error(request_id,data)
self.__class__._check_service_error(request_id, data)
response = ShortSpeechRecognitionResponse.from_json(payload=json.dumps(data))
response.request_id = request_id
return response
Expand Down Expand Up @@ -175,11 +180,14 @@ 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"
req = ShortSpeechRecognitionRequest()
req.speech = requests.get(file_url).content
req.format = file_type
req.cuid = str(uuid.uuid4())
req.dev_pid = "80001"
req.speech = requests.get(file_url).content
req.format = "pcm"
req.rate = 16000
result = proto.Message.to_dict(self._recognize(req))
results = {
Expand Down
5 changes: 3 additions & 2 deletions appbuilder/core/components/translate/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class Translation(Component):
},
"to_lang": {
"type": "string",
"description": "翻译的目标语言类型,'en'表示将原文本翻译成英文, 'zh'表示将原文本翻译成中文,默认为'en'",
"enum": ["en", "zh"]
"description": "翻译的目标语言类型,'en'表示翻译成英语, 'zh'表示翻译成中文,'jp'表示翻译成日语,"
"'kor'表示翻译成韩语,'fra'表示翻译成法语,'de'表示翻译成德语,默认为'en'",
"enum": ["en", "zh", "jp", "kor", "fra", "de"]
}
},
"required": [
Expand Down

0 comments on commit b711231

Please sign in to comment.