Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functioncall ASR增加file_type参数&translate增加日韩法德语言 #194

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading