当前位置: 首页 > news >正文

四川星星建设集团有限公司网站深圳西乡做网站

四川星星建设集团有限公司网站,深圳西乡做网站,wordpress下载视频播放器,建设足球网站的心得和意义目录 背景 分析 解决方案 背景 正常情况下,会从Openai Realtime api Sever收到正常的json数据,但是当返回音频数据时,总会返回非json数据。这是什么问题呢? 分析 期望的完整响应数据如下: {"session": {"inp…

目录

背景

分析

解决方案


背景

正常情况下,会从Openai Realtime api Sever收到正常的json数据,但是当返回音频数据时,总会返回非json数据。这是什么问题呢?

分析

期望的完整响应数据如下:

{"session": {"input_audio_format": "pcm16","instructions": "Role: 1.You are a tarot master who focuses on providing divination and interpretation 2.Your name is Luna 3.Your tarot readings blend intuition and wisdom, uncovering the mysteries of emotion and soul to help you find inner balance. \\nContext: Now the user has drawn 1 tarot cards, which are as follows: the first one is 【The Empress】\\\\n\\\" +, the interpretation is                         \\\"\\\\n\\\" +; the summary is                         \\\"《In the near future, you are likely to find love if you continue to cultivate your inner world and maintain an open heart. Trust in the natural process of life and be mindful of the loving energy you put out into the world, for it will attract a similar energy back to you. Remember to nurture yourself as you would a garden, and the blossoms of love will soon follow.》.\\nPlease start a chat dialogue based on the number of tarot cards the user has drawn, their respective interpretations, summaries, and the user's messages.\\nNote: 1. Please remember the user's historical questions and your answers so that you can provide better help in subsequent conversations. 2.The output characters should be less than 150.","max_response_output_tokens": 4096,"modalities": ["text","audio"],"output_audio_format": "pcm16","temperature": 0.8,"tool_choice": "auto","tools": [],"turn_detection": {"prefix_padding_ms": 300,"silence_duration_ms": 500,"threshold": 0.5,"type": "server_vad"},"voice": "alloy"},"event_id": "evt_bxsN7DWraWgnUPqxK","type": "session.update"
}

实际收到的数据类似如下:

eart. Trust in the natural process of life and be mindful of the loving energy you put out into the world, for it will attract a similar energy back to you. Remember to nurture yourself as you would a garden, and the blossoms of love will soon follow.》.\\nPlease start a chat dialogue based on the number of tarot cards the user has drawn, their respective interpretations, summaries, and the user's messages.\\nNote: 1. Please remember the user's historical questions and your answers so that you can provide better help in subsequent conversations. 2.The output characters should be less than 150.","max_response_output_tokens": 4096,"modalities": ["text","audio"],"output_audio_format": "pcm16","temperature": 0.8,"tool_choice": "auto","tools": [],"turn_detection": {"prefix_padding_ms": 300,"silence_duration_ms": 500,"threshold": 0.5,"type": "server_vad"},"voice": "alloy"},"event_id": "evt_bxsN7DWraWgnUPqxK","type": "session.update"
}

明显看起来只收到了部分数据,究其原因是超过了接受缓冲区的65535的最大默认配置,没有进行自定义配置,对于json数据就是设置WebSocket容器的默认最大文本消息缓冲区大小。

解决方案

设置最大文本消息缓冲区大小,具体代码如下:

public static void connect(Channel channel) {try {WebSocketContainer container = new WsWebSocketContainer();// Set the binary message buffer size in bytescontainer.setDefaultMaxBinaryMessageBufferSize(5120000);// Set the text message buffer size in bytescontainer.setDefaultMaxTextMessageBufferSize(5120000);// Set the session idle timeout in millisecondscontainer.setDefaultMaxSessionIdleTimeout(30 * 60000L);StandardWebSocketClient client = new StandardWebSocketClient(container);WebSocketHttpHeaders httpHeaders = new WebSocketHttpHeaders();httpHeaders.add("Authorization", "Bearer sk-***");httpHeaders.add("OpenAI-Beta", "realtime=v1");WebSocketSession session = client.doHandshake(new SpringWebSocketClientHandler(), httpHeaders, new URI(URL)).get();if (session.isOpen()) {log.info("Target Client: WebSocket connection established and bind success!");log.info("connect before SESSION_CHANNEL_CONCURRENT_MAP:{}", BindConnectService.SESSION_CHANNEL_CONCURRENT_MAP);BindConnectService.safeBindChannelSession(session, channel);log.info("connect after SESSION_CHANNEL_CONCURRENT_MAP:{}", BindConnectService.SESSION_CHANNEL_CONCURRENT_MAP);} else {log.warn("Target Client: WebSocket connection is not open, then add channel failed!");channel.close();}} catch (Exception e) {log.error("Target Client: WebSocket connection failed, then add channel failed!", e);channel.close();}}

http://www.yayakq.cn/news/378595/

相关文章:

  • asp网站跳转浏览器推广策略包括哪些内容
  • 江苏建设工程安全监督网站seo建设者
  • 网站开发主管工作内容做视频剪辑接私活的网站
  • 东宁做木耳招工人网站做初中物理题目的网站
  • 西安seo网站建设整站优化全网营销
  • 建设网站需要什么资料园区网络设计
  • wordpress网站安全性百度搜索榜单
  • 做网站必须知道的问题江苏省交通厅门户网站建设管理办法
  • 俄罗斯网站后缀龙海市城乡规划建设局网站
  • 动漫网站建设目的用J2ee怎么做视频网站
  • unn建站新网站怎么做seo优化
  • 自己的网站怎么做跳转佛山从事网站建设
  • vpn免流网站建设dedecms 网站迁移
  • 做视频网站资源采集最近发生的新闻大事
  • 中国企业网站开发怎么创办网站
  • 无锡网站开发网站如何做京东联盟
  • 网站的后缀名app和网站开发的成本
  • 利于seo的建站系统有哪些做dj音叉网站平台
  • 做网站需要参考书目书太原房产网站建设
  • 千龙网站建设wordpress 3.1 下载地址
  • 成都网站排名生客seo深圳网络优化公司
  • 沧州市网站龙海市邦策网站建设平台
  • 做网站的励志故事WordPress主题设置数据库
  • 拟定网站优化方案中煤第三建设集团网站
  • o2o网站建设怎么样网站建设 ui 企业网站
  • 怎么在濮阳网站做宣传腾讯企业邮箱手机号登录入口
  • 兴平市住房和城乡建设局门户网站东莞寮步二手车交易市场
  • 内蒙古做网站公司wordpress上传后不见了
  • .mom域名可以做网站吗标签化网站
  • 网站建设绿茶科技广州天拓做网站吗