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

一键做网站的软件电脑培训中心

一键做网站的软件,电脑培训中心,青岛建筑网,做网站是否要去工商备案目录 背景 分析 解决方案 背景 正常情况下,会从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/828962/

相关文章:

  • 重庆市建设工程信息网站诚信分最新项目首码发布平台
  • 嘉兴网站建设嘉兴二手房出售信息
  • 麦包包的网站建设分析中英文企业网站
  • 区域网站设计宁波论坛招聘
  • 网站特效怎么做的我爱你域名的网站
  • 学校网站开发与实现的解决思路微信app下载安卓版官方下载
  • 西湖网站建设ftp查看网站后台密码
  • 网站建设的特点云服务器网站崩溃的原因
  • 专业模板网站制作多少钱局域网端口映射做网站
  • 织梦的手机端网站河南网络优化服务
  • 漳州做网站最便宜按效果付费的网络推广方式
  • 怎样增加网站的权重做外贸网站需要注意哪些
  • 如何用js做网站阳山网站seo
  • 网站制作和美工景安服务器安装wordpress
  • 网站建设 好公司长沙网站建设公司联系方式
  • 广西住房城乡建设厅网站怎么下载随申办app
  • 最新新闻热点事件2022年8月企业seo推广的绝密诀窍曝光
  • 织梦 公司网站模板wordpress 多域名绑定域名
  • 做网站客户怎么找wordpress 生命周期
  • 建设网站怎么添加端口映射wordpress去category
  • 网上网站怎么做如何制作多网页网站
  • 用phpcms做的网站模板泰安新闻
  • 游戏 网站 模板百度竞价外包
  • 网站总体设计就业合同模板
  • 网站备案能查到什么东西广州市天河区建设局网站
  • 无障碍网站建设的意义四川建设厅证网站是
  • 彬县网站建设黑帽seo技术论坛
  • 中国政务网站建设绩效评估网站的建设步骤
  • php网站iis设置域名抢注网站建设
  • 雄安免费网站建设成都建设银行合作装修网站