Skip to content

Commit 64c03ee

Browse files
committed
fix: fix tts node and stt node error
--bug=1050817 --user=王孝刚 【应用编排】文本转语音,字数不是很多但是模型提示超长了 https://www.tapd.cn/57709429/s/1636787 --bug=1050821 --user=王孝刚 【应用编排】语音转文本错误信息是图片缺少file_id https://www.tapd.cn/57709429/s/1636786
1 parent ae7c446 commit 64c03ee

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

apps/application/flow/step_node/speech_to_text_step_node/i_speech_to_text_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _run(self):
2727
self.node_params_serializer.data.get('audio_list')[1:])
2828
for audio in res:
2929
if 'file_id' not in audio:
30-
raise ValueError("参数值错误: 上传的图片中缺少file_id,音频上传失败")
30+
raise ValueError("参数值错误: 上传的音频中缺少file_id,音频上传失败")
3131

3232
return self.execute(audio=res, **self.node_params_serializer.data, **self.flow_params_serializer.data)
3333

apps/application/flow/step_node/text_to_speech_step_node/impl/base_text_to_speech_node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def execute(self, tts_model_id, chat_id,
5858
file_url = FileSerializer(data={'file': file, 'meta': meta}).upload()
5959
# 拼接一个audio标签的src属性
6060
audio_label = f'<audio src="{file_url}" controls style = "width: 300px; height: 43px"></audio>'
61-
return NodeResult({'answer': audio_label, 'result': audio_label}, {})
61+
file_id = file_url.split('/')[-1]
62+
audio_list = [{'file_id': file_id, 'file_name': file_name, 'url': file_url}]
63+
return NodeResult({'answer': audio_label, 'result': audio_list}, {})
6264

6365
def get_details(self, index: int, **kwargs):
6466
return {

apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ def text_to_speech(self, text):
8585
"uid": "uid"
8686
},
8787
"audio": {
88-
"encoding": "mp3",
89-
"volume_ratio": 1.0,
90-
"pitch_ratio": 1.0,
91-
} | self.params,
88+
"encoding": "mp3",
89+
"volume_ratio": 1.0,
90+
"pitch_ratio": 1.0,
91+
} | self.params,
9292
"request": {
9393
"reqid": str(uuid.uuid4()),
9494
"text": '',
@@ -113,7 +113,7 @@ async def submit(self, request_json, text):
113113
result = b''
114114
async with websockets.connect(self.volcanic_api_url, extra_headers=header, ping_interval=None,
115115
ssl=ssl_context) as ws:
116-
lines = text.split('\n')
116+
lines = [text[i:i + 200] for i in range(0, len(text), 200)]
117117
for line in lines:
118118
if self.is_table_format_chars_only(line):
119119
continue

0 commit comments

Comments
 (0)