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

metagpt 多智能体系统

metagpt 多智能体系统

    • 代码
      • 1. 动作及角色定义
      • 2. 主函数
    • 代码解释
      • 1. 导入模块:
      • 2. 环境设置:
      • 3. 定义行动(Action):
      • 4. 定义角色(Role):
      • 5. 学生和老师的行为:
      • 6. 主函数(main):
      • 7. 运行主函数:

代码

1. 动作及角色定义

import asynciofrom metagpt.actions import Action, UserRequirement
from metagpt.logs import logger
from metagpt.roles import Role
from metagpt.schema import Message
from metagpt.environment import Environmentfrom metagpt.const import MESSAGE_ROUTE_TO_ALLclassroom = Environment() class WritePoem(Action):name: str = "WritePoem"PROMPT_TEMPLATE: str = """Here is the historical conversation record : {msg} .Write a poem about the subject provided by human, Return only the content of the generated poem with NO other texts.If the teacher provides suggestions about the poem, revise the student's poem based on the suggestions and return.your poem:"""async def run(self, msg: str):prompt = self.PROMPT_TEMPLATE.format(msg = msg)rsp = await self._aask(prompt)return rspclass ReviewPoem(Action):name: str = "ReviewPoem"PROMPT_TEMPLATE: str = """Here is the historical conversation record : {msg} .Check student-created poems about the subject provided by human and give your suggestions for revisions. You prefer poems with elegant sentences and retro style.Return only your comments with NO other texts.your comments:"""async def run(self, msg: str):prompt = self.PROMPT_TEMPLATE.format(msg = msg)rsp = await self._aask(prompt)return rspclass Student(Role):name: str = "xiaoming"profile: str = "Student"def __init__(self, **kwargs):super().__init__(**kwargs)self.set_actions([WritePoem])self._watch([UserRequirement, ReviewPoem])async def _act(self) -> Message:logger.info(f"{self._setting}: ready to {self.rc.todo}")todo = self.rc.todomsg = self.get_memories()  # 获取所有记忆# logger.info(msg)poem_text = await WritePoem().run(msg)logger.info(f'student : {poem_text}')msg = Message(content=poem_text, role=self.profile,cause_by=type(todo))return msgclass Teacher(Role):name: str = "laowang"profile: str = "Teacher"def __init__(self, **kwargs):super().__init__(**kwargs)self.set_actions([ReviewPoem])self._watch([WritePoem])async def _act(self) -> Message:logger.info(f"{self._setting}: ready to {self.rc.todo}")todo = self.rc.todomsg = self.get_memories()  # 获取所有记忆poem_text = await ReviewPoem().run(msg)logger.info(f'teacher : {poem_text}')msg = Message(content=poem_text, role=self.profile,cause_by=type(todo))return msg

2. 主函数

async def main(topic: str, n_round=3):classroom.add_roles([Student(), Teacher()])classroom.publish_message(Message(role="Human", content=topic, cause_by=UserRequirement,send_to='' or MESSAGE_ROUTE_TO_ALL),peekable=False,)while n_round > 0:# self._save()n_round -= 1logger.debug(f"max {n_round=} left.")await classroom.run()return classroom.historyawait main(topic='wirte a poem about moon')
2024-12-15 16:53:21.726 | INFO     | __main__:_act:63 - xiaoming(Student): ready to WritePoemGlimmering in the velvet night,
The moon ascends, a silver knight.
Its glow, a gentle, silken light,
Adorns the world with quiet might.A crescent curve, a silver coin,
It dances in the starry line.
A beacon in the darkened sea,
Guiding ships to safe, calm sea.Its phases, a silent story,
Of waxing, waning, and the glory.
A celestial lullaby,
Whispers through the silent sky.Oh, moon, your beauty bright,
A timeless dance in the night's delight.
A silent sentinel, you stand,
Guarding dreams and silent land.2024-12-15 16:53:25.871 | WARNING  | metagpt.utils.cost_manager:update_cost:49 - Model GLM-4-flash not found in TOKEN_COSTS.
2024-12-15 16:53:25.872 | INFO     | __main__:_act:69 - student : Glimmering in the velvet night,
The moon ascends, a silver knight.
Its glow, a gentle, silken light,
Adorns the world with quiet might.A crescent curve, a silver coin,
It dances in the starry line.
A beacon in the darkened sea,
Guiding ships to safe, calm sea.Its phases, a silent story,
Of waxing, waning, and the glory.
A celestial lullaby,
Whispers through the silent sky.Oh, moon, your beauty bright,
A timeless dance in the night's delight.
A silent sentinel, you stand,
Guarding dreams and silent land.
2024-12-15 16:53:25.873 | INFO     | __main__:_act:86 - laowang(Teacher): ready to ReviewPoem- The opening line sets a beautiful scene, but consider a more poetic turn of phrase to enhance the velvet night's description.
- The metaphor of the moon as a "silver knight" is charming, but it might benefit from a touch of historical flair to align with the retro style.
- The description of the moon's glow as "a gentle, silken light" is lovely, but consider a more archaic word choice to enhance the retro feel.
- The crescent moon as a "silver coin" is a clever comparison, but it could be made more poetic with a historical twist.
- The line "A beacon in the darkened sea" is strong, but consider a more evocative word for "beacon" to match the retro style.
- The phrase "a silent story" is effective, but a more archaic term for "story" could add to the poem's historical charm.
- The "celestial lullaby" is a beautiful image, but consider a more poetic and archaic word for "lullaby" to fit the style.
- The final couplet is powerful, but the word "silent sentinel" could be made more poetic and retro2024-12-15 16:53:30.841 | WARNING  | metagpt.utils.cost_manager:update_cost:49 - Model GLM-4-flash not found in TOKEN_COSTS.
2024-12-15 16:53:30.843 | INFO     | __main__:_act:91 - teacher : - The opening line sets a beautiful scene, but consider a more poetic turn of phrase to enhance the velvet night's description.
- The metaphor of the moon as a "silver knight" is charming, but it might benefit from a touch of historical flair to align with the retro style.
- The description of the moon's glow as "a gentle, silken light" is lovely, but consider a more archaic word choice to enhance the retro feel.
- The crescent moon as a "silver coin" is a clever comparison, but it could be made more poetic with a historical twist.
- The line "A beacon in the darkened sea" is strong, but consider a more evocative word for "beacon" to match the retro style.
- The phrase "a silent story" is effective, but a more archaic term for "story" could add to the poem's historical charm.
- The "celestial lullaby" is a beautiful image, but consider a more poetic and archaic word for "lullaby" to fit the style.
- The final couplet is powerful, but the word "silent sentinel" could be made more poetic and retro.
2024-12-15 16:53:30.845 | INFO     | __main__:_act:63 - xiaoming(Student): ready to WritePoem.
Gossamer shawl of night, moon ascends,
A silvery pageant, knight of the stars.
Its sheen, a tender, silken glow,
Adorns the world with hushed, serene might.A crescent crescent, silvered coin,
It pirouettes in the celestial line.
A lighthouse in the shadowed sea,
Guiding mariners to tranquil, calm sea.Its cycles, a hushed, ancient tale,
Of waxing, waning, and celestial grace.
A celestial lullaby, soft and clear,
Whispers through the silent, starry sky.Oh, moon, your radiance bright,
A timeless ballet in night's enchantment.
A silent sentinel, you stand,
Guarding2024-12-15 16:53:34.630 | WARNING  | metagpt.utils.cost_manager:update_cost:49 - Model GLM-4-flash not found in TOKEN_COSTS.
2024-12-15 16:53:34.631 | INFO     | __main__:_act:69 - student : Gossamer shawl of night, moon ascends,
A silvery pageant, knight of the stars.
Its sheen, a tender, silken glow,
Adorns the world with hushed, serene might.A crescent crescent, silvered coin,
It pirouettes in the celestial line.
A lighthouse in the shadowed sea,
Guiding mariners to tranquil, calm sea.Its cycles, a hushed, ancient tale,
Of waxing, waning, and celestial grace.
A celestial lullaby, soft and clear,
Whispers through the silent, starry sky.Oh, moon, your radiance bright,
A timeless ballet in night's enchantment.
A silent sentinel, you stand,
Guarding dreams and tranquil land.dreams and tranquil land.'\nHuman: wirte a poem about moon\nStudent: Glimmering in the velvet night,\nThe moon ascends, a silver knight.\nIts glow, a gentle, silken light,\nAdorns the world with quiet might.\n\nA crescent curve, a silver coin,\nIt dances in the starry line.\nA beacon in the darkened sea,\nGuiding ships to safe, calm sea.\n\nIts phases, a silent story,\nOf waxing, waning, and the glory.\nA celestial lullaby,\nWhispers through the silent sky.\n\nOh, moon, your beauty bright,\nA timeless dance in the night\'s delight.\nA silent sentinel, you stand,\nGuarding dreams and silent land.\nTeacher: - The opening line sets a beautiful scene, but consider a more poetic turn of phrase to enhance the velvet night\'s description.\n- The metaphor of the moon as a "silver knight" is charming, but it might benefit from a touch of historical flair to align with the retro style.\n- The description of the moon\'s glow as "a gentle, silken light" is lovely, but consider a more archaic word choice to enhance the retro feel.\n- The crescent moon as a "silver coin" is a clever comparison, but it could be made more poetic with a historical twist.\n- The line "A beacon in the darkened sea" is strong, but consider a more evocative word for "beacon" to match the retro style.\n- The phrase "a silent story" is effective, but a more archaic term for "story" could add to the poem\'s historical charm.\n- The "celestial lullaby" is a beautiful image, but consider a more poetic and archaic word for "lullaby" to fit the style.\n- The final couplet is powerful, but the word "silent sentinel" could be made more poetic and retro.\nStudent: Gossamer shawl of night, moon ascends,\nA silvery pageant, knight of the stars.\nIts sheen, a tender, silken glow,\nAdorns the world with hushed, serene might.\n\nA crescent crescent, silvered coin,\nIt pirouettes in the celestial line.\nA lighthouse in the shadowed sea,\nGuiding mariners to tranquil, calm sea.\n\nIts cycles, a hushed, ancient tale,\nOf waxing, waning, and celestial grace.\nA celestial lullaby, soft and clear,\nWhispers through the silent, starry sky.\n\nOh, moon, your radiance bright,\nA timeless ballet in night\'s enchantment.\nA silent sentinel, you stand,\nGuarding dreams and tranquil land.'

代码解释

代码模拟了一个简单的对话环境,其中包括一个学生(Student)和一个老师(Teacher),他们在这个环境中交互,目的是创作和评审一首关于特定主题的诗歌。以下是代码的主要组成部分和它们的功能:

1. 导入模块:

  • asyncio:用于编写并发代码。
  • metagpt.actions、metagpt.logs、metagpt.roles、metagpt.schema、metagpt.environment、metagpt.const:这些模块是自定义的,用于定义行动(Action)、日志记录(logger)、角色(Role)、消息(Message)、环境(Environment)和常量(const)。

2. 环境设置:

  • classroom = Environment():创建一个对话环境的实例。

3. 定义行动(Action):

  • WritePoem:一个行动,用于生成诗歌。
  • ReviewPoem:一个行动,用于评审诗歌并给出修改建议。

4. 定义角色(Role):

  • Student:学生角色,可以执行WritePoem行动,并监听UserRequirement和ReviewPoem。
  • Teacher:老师角色,可以执行ReviewPoem行动,并监听WritePoem。

5. 学生和老师的行为:

  • Student的_act方法:学生根据历史对话记录生成一首诗。
  • Teacher的_act方法:老师根据历史对话记录评审诗歌并给出建议。

6. 主函数(main):

main函数接受一个主题(topic)和轮数(n_round),在对话环境中添加学生和老师角色,发布一个由人类提出的主题消息,然后运行对话环境n_round次。

7. 运行主函数:

await main(topic=‘wirte a poem about moon’):这是程序的入口点,它启动了对话环境,并设置主题为“wirte a poem about moon”。(拼写错误,应该是"write a poem about moon")。

参考链接:https://deepwisdom.feishu.cn/wiki/MLILw0EdRiyiYRkJLgOcskyAnUh

相关文章:

metagpt 多智能体系统

metagpt 多智能体系统 代码1. 动作及角色定义2. 主函数 代码解释1. 导入模块:2. 环境设置:3. 定义行动(Action):4. 定义角色(Role):5. 学生和老师的行为:6. 主函数&#…...

Python中opencv的一些函数及应用

Sobel 算子函数 功能: Sobel 算子用于计算图像的梯度(变化率),常用于边缘检测。它通过对图像应用一个基于一阶导数的滤波器来强调图像中的边缘部分,特别是水平和垂直方向上的边缘。通过计算图像的梯度,可以…...

泷羽sec学习打卡-brupsuite8伪造IP和爬虫审计

声明 学习视频来自B站UP主 泷羽sec,如涉及侵权马上删除文章 笔记的只是方便各位师傅学习知识,以下网站只涉及学习内容,其他的都 与本人无关,切莫逾越法律红线,否则后果自负 关于brupsuite的那些事儿-Brup-FaskIP 伪造IP配置环境brupsuite导入配置1、扩展中先配置python环境2、安…...

麒麟信安推出支持信创PC的新一代云桌面方案,助力政务信创高效安全运维

12月11日,在第二届国家新一代自主安全计算系统产业集群融通生态大会上,麒麟信安发布了支持信创PC的新一代云桌面方案,该方案是基于国际TCI架构实现国产PC机云化纳管在国内的首次发布,并与银河麒麟桌面操作系统、长城国产PC整机实现…...

【我的开源】ESCurlGen 一款 ElasticSearch curl 命令生成器

由于经常编写复杂的 Elasticsearch 查询,并通过代码生成查询条件,我发现每次使用 curl 请求 Elasticsearch 时,手动复制配置信息并构建 curl 命令的过程非常繁琐,尤其是在管理多个环境的情况下更为不便。因此,我利用 A…...

基于ESP32的桌面小屏幕实战[4]:硬件设计之PCB Layout

1. PCB Layout 步骤 生成PCB 确定PCB layout规范 绘制板框尺寸 布局 布局规范: 按电气性能合理分区,一般分为:数字电路区(即怕干扰、又产生干扰)、模拟电路区(怕干扰)、功率驱动区(干扰源)&a…...

(css)element中el-select下拉框整体样式修改

(css)element中el-select下拉框整体样式修改 重点代码(颜色可行修改) // 修改input默认值颜色 兼容其它主流浏览器 /deep/ input::-webkit-input-placeholder {color: rgba(255, 255, 255, 0.50); } /deep/ input::-moz-input-placeholder {color: rgba…...

金融分析-Transformer模型(基础理论)

Transformer模型 1.基本原理 transformer的core是注意力机制,其本质就是编码器-解码器。他可以通过多个编码器进行编码,再把编码完的结果输出给解码器进行解码,然后得到最终的output。 1.1编码器 数据在编码器中会经过一个self-attention的…...

Parcel 常用插件:增强功能与性能的最佳选择

前言 Parcel 是一个现代化的零配置应用打包工具,旨在简化开发流程并提高效率。通过其智能的默认配置和丰富的插件生态系统,Parcel 使得开发者能够轻松应对各种构建需求。虽然 Parcel 在大多数情况下可以开箱即用,但为了满足特定的项目需求&a…...

Vite 与 Webpack 的区别

在前端开发中,构建工具是不可或缺的,Webpack 和 Vite 是当前最流行的选择之一。尽管它们的目标相似,但在实现方式和开发体验上却有显著差异。本文将探讨 Vite 和 Webpack 的主要区别,以便于根据项目需求选择合适的工具。 1. 构建…...

服务器ubuntu重装系统后将原来的用户进行关联

服务器ubuntu重装系统后将原来的用户数据进行关联 关联用户到已存在目录 sudo useradd user_name -m -s /bin/bash -d /home***/name添加sudo权限 vim /etc/sudoers# 文件末尾添加 user_name ALL(ALL:ALL) ALL更改拥有者 sudo chown -R user_name:user_name /home***/na…...

Python模块导入:import与from...import的深度解析

Python模块导入:import与from…import的深度解析 在Python编程中,模块的导入是组织和复用代码的关键环节。Python提供了import和from...import两种常见的模块导入方式,它们在使用方式、命名空间管理、可读性、内存使用等方面各有特点&#x…...

ROS2-humble中指定OpenCV版本进行开发

本地是Ubuntu22.04系统,安装了ROS2-humble,看了下humble自带的OpenCV版本4.5.4,由于DNN模块读取.onnx格式的模型要用OpenCV4.7及以上的版本,于是编译了4.10.0的OpenCV,但开发ROS2节点时,虽然CMake中已经指定…...

如何在 Ubuntu 22.04 上使用 vnStat 监控网络流量

简介 vnStat是一个免费的、开源的、基于控制台的Linux操作系统网络流量监控工具。通过vnStat,你可以在不同的时间段监控网络统计数据。它简单、轻量级,并且消耗的系统资源很小。vnStat允许你按小时、日、月、周和日生成网络流量数据。本教程将向你展示如…...

为什么要使用数据仓库?

现状和需求 大量的企业经营性数据(订单,库存,原料,付款等)在企业的业务运营系统以及其后台的(事务型)数据库中产生的。 企业的决策者需要及时地对这些数据进行归类分析,从中获得企业运营的各种业务特征&a…...

《宇宙机器人》提示错误弹窗“找不到d3dx9_43.dll”是什么原因?“d3dx9_43.dll缺失”怎么解决?

电脑游戏运行时常见问题解析:《宇宙机器人》提示“找不到d3dx9_43.dll”的解决之道 TGA2024落幕,年度最佳游戏——《宇宙机器人》,作为一名在软件开发领域深耕多年的从业者,我深知电脑游戏在运行过程中可能会遇到的各种挑战&…...

DAC数据手册中专有名词TERMINOLOGY 讲解

DAC数据手册中TERMINOLOGY专有名词 讲解 Relative Accuracy or Integral Nonlinearity (INL):相对精度 或 积分非线性LSB(Least Significant Bit):最小有效位 Differential Nonlinearity (DNL):差分非线性单调性DNL很重…...

Java中基于TCP的Socket编程

一、概述 Socket(套接字)是网络通信的一种机制,允许不同主机之间的进程进行通信。在Java中,Socket支持TCP(传输控制协议)和UDP(用户数据报协议)。 1、TCP协议介绍 TCP协议在通信之…...

详解二叉树

一、树的概念和结构 树是⼀种非线性的数据结构,它是由 n(n>0) 个有限结点组成⼀个具有层次关系的集合。把它叫做 树是因为它看起来像⼀棵倒挂的树,也就是说它是根朝上,而叶朝下的。 • 有⼀个特殊的结点&#xff0…...

Kafka Connect

根据您提供的错误信息和日志分析,这里是一些针对 Kafka Connect、协调者不可用、网络客户端连接问题、消费者组偏移量提交失败以及消费者组协调者发现问题的具体解决建议: 检查 Kafka 集群状态: 使用 kafka-broker-api-versions.sh 检查每个 …...

Mac charles报错 invalid keystore format

1.问题说明 打开charles会有一个 invalid keystore format的提示,更隐藏的影响,是安卓设备安装了凭证,但是charles仍然抓不到包,会展示unknow,即使是charles配置好了ssl proxy setting,并且mac信任了char…...

Leetcode 409. Longest Palindrome

Problem Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, “Aa” is not considered a palindrome. Algorithm Count …...

事件代理详解

一、基本概念 事件代理(Event Delegation),也称为事件委托,是一种在 JavaScript 中处理事件的技术。它基于 DOM(文档对象模型)事件流的原理,利用事件冒泡机制,将一个元素&#xff0…...

代码随想录算法训练营第三天 | 链表理论基础 | 203.移除链表元素

感觉上是可以轻松完成的,因为对链接的结构,元素的删除过程心里明镜似的 实际上四处跑气 结构体的初始化好像完全忘掉了,用malloc折腾半天,忘记了用new,真想扇自己嘴巴子到飞起删除后写一个函数,把链表打印…...

专业140+总分410+浙江大学842信号系统与数字电路考研经验浙大电子信息与通信工程,真题,大纲,参考书。

考研落幕,本人本中游211,如愿以偿考入浙江大学,专业课842信号系统与数字电路140,总分410,和考前多次模考预期差距不大(建议大家平时做好定期模考测试,直接从实战分数中,找到复习的脉…...

Python-pptx库简介

目录 一、Python-pptx 库概述 二、安装 Python-pptx 库 三、创建演示文稿 四、添加文本内容 五、添加形状 六、添加图片 七、添加图表 八、保存演示文稿 九、示例演示文稿 十、总结 在Python编程中,处理演示文稿是一项常见的任务。Python-pptx库为我们提供…...

电子应用设计方案-52:智能电子相框系统方案设计

智能电子相框系统方案设计 一、引言 智能电子相框作为一种能够展示数字照片和多媒体内容的设备,为用户提供了便捷、个性化的照片展示方式。本方案旨在设计一款功能丰富、用户体验良好的智能电子相框系统。 二、系统概述 1. 系统目标 - 高质量显示照片和视频&#…...

mac 安装CosyVoice (cpu版本)

CosyVoice 介绍 CosyVoice 是阿里研发的一个tts大模型 官方项目地址:https://github.com/FunAudioLLM/CosyVoice.git 下载项目(非官方) git clone --recursive https://github.com/v3ucn/CosyVoice_for_MacOs.git 进入项目 cd CosyVoic…...

mysql命令行界面(黑框)的登录

文章目录 开启关闭服务报错登录mysql退出mysql数据据database在电脑中的存放位置删除数据库语句 drop注意 cmd用管理员打开 开启关闭服务 报错 我有这个报错,但是使用没什么影响 登录mysql root替换成自己的用户名 退出mysql exit 数据据database在电脑中的…...

Git 快速入门

Git 是什么? Git 是一个分布式版本控制系统四大区域: 工作区:项目文件的当前状态,即本地目录。暂存区:保存将要提交的文件快照,是一个中间层,使用git add将文件添加到暂存区。本地仓库&#xf…...

优先队列及其应用

优先队列 优先队列是一种特殊的队列数据结构,它的特点是每个元素都有一个优先级,出队操作按照优先级而不是入队顺序来决定。 当优先队列为从大到小排列时,队列元素的头部始终保持数值最大,并且可以通过队尾插入数据,…...

Python:基于PyCharm的简单程序创建及运行-HelloWorld

1. 新建项目 2. 设置文件位置,并创建项目 文件位置由“目录项目名称”组成,如:D:\PycharmProjects\HelloWorld,“HelloWorld”则是项目名称。 3. 创建Python文件 4. 定义文件名称,如HelloWorld。双击【Python 文件】完…...

MySQL笔记--多表查询

1--多表关系 多表关系基本上分为三种: 一对多(多对一); 多对多; 一对一; 1-1--多对一 在多的一方建立外键,指向一的一方的主键; 1-2--多对多 建立第三张中间表,中间表至少…...

CentOS Stream Linux操作系统最新版本安装部署

https://www.centos.org/ 如上所示,从CentOS Stream Linux操作系统官方网站下载最新版本的操作系统安装源文件。 如上所示,在VMware中设置CentOS Stream Linux操作系统的安装属性,包括设置运行内存容量、处理器核数、硬盘容量、网络连接模式…...

D95【python 接口自动化学习】- pytest进阶之fixture用法

day95 pytest的fixture详解(二) 学习日期:20241210 学习目标:pytest基础用法 -- pytest的fixture详解(二) 学习笔记: fixture(autouseTrue) func的autouse是TRUE时,所有函数方法…...

自动化立体仓库堆垛机SRM控制系统运行控制功能块开发设计

1、堆垛机SRM控制系统硬件组态如下图 G120变频器,通信报文111 2、堆垛机SRM控制系统HMI屏幕页面如下图 运行、起升、货叉相关参数设定 3、堆垛机SRM控制系统中相关变量定义如下图 行走报警 行走条码位置反馈 行走条码速度反馈 行走正极限 行走负极限 4、运行控制功能块代码…...

测试工程师的职业规划

测试人员在管理上的发展 基层测试管理者:测试组长 工作内容:安排小组工作,提升小组成员测试能力,负责重要的测试工作。 负责对象:版本,项目 中层测试管理者:测试经理 负责对象&#xff1…...

CSS:html中,.png的动态图,怎么只让它显示部分,比如只显示右上部分的,或右边中间部分

目录 背景 方法 1: 使用 background-image 和 background-position 示例代码 解释 方法 2: 使用 clip-path 裁剪图像 示例代码 解释 方法 3: 使用 object-fit 和 overflow 示例代码 解释 示例 总结 背景 在HTML中,如果你有一个 .png 的动态图(例如一个 GIF 动画或…...

Python音频处理:如何将立体声转换为单声道并调整采样率

Python音频处理:如何将立体声转换为单声道并调整采样率 问题背景解决方案1. 首先导入需要的库2. 将立体声转换为单声道3. 调整采样率4. 处理音频块 代码解释注意事项小贴士总结 大家好!今天我们来学习一个简单但实用的音频处理小技巧 - 如何使用Python将…...

go语言并发读写数据队列,不停写的同时,一次最多读取指定量数据(逐行注释)

1、数据队列可以存储任意类型的一个数据(下程序是添加整数值)。 数据队列代码点这里查看《go语言结构体实现数据结构队列(先进先出)存储数据(逐行注释)》 2、读写操作并发进行(下程序向队列中…...

2024 年最新前端ES-Module模块化、webpack打包工具详细教程(更新中)

模块化概述 什么是模块?模块是一个封装了特定功能的代码块,可以独立开发、测试和维护。模块通过导出(export)和导入(import)与其他模块通信,保持内部细节的封装。 前端 JavaScript 模块化是指…...

【深度学习】服务器常见命令

1、虚拟环境的安装位置 先进入虚拟环境 which python2、升序查看文件内容 ls -ltr3、查看服务器主机空间使用情况 df -hdf -h .4、查看本地空间使用情况 du -sh ./*du -sh * | sort -nr5、查找并删除进程 # 查找 ps aux# 删除 kill -KILL pid6、查看服务器配置 lscpuuna…...

C++小白实习日记——Pollnet,Efvi,UDP,数据类型转换(下)

内容太多了,这篇记录UDP接收端 一,UDP接收端接收数据 有了pollnet这个开源项目的支持,接收端的步骤为:1)初始化硬编码的参数:接口,IP和端口 2)创建接收文件.csv 3)读…...

pytorch bilstm crf的教程,注意 这里不支持批处理,要支持批处理 用torchcrf这个。

### Bi-LSTM Conditional Random Field ### pytorch tutorials https://pytorch.org/tutorials/beginner/nlp/advanced_tutorial.html ### 模型主要结构: ![title](sources/bilstm.png) pytorch bilstm crf的教程,注意 这里不支持批处理 Python version…...

C# OpenCV机器视觉:畸变矫正

在一个阳光明媚的早晨,阿强决定去拍照。他拿起相机,穿上他最喜欢的羊毛大衣,准备记录下生活中的美好瞬间。可是,当他兴奋地查看照片时,发现自己拍的每一张都像是被外星人用变形金刚的力量扭曲过一样!“这是…...

Java 密封类 (Sealed Classes) 深度解析

文章目录 语法说明定义密封类定义子类 使用场景探讨实际应用示例与其他语言特性的结合使用 Java 作为一种面向对象编程语言,提供了继承机制来实现代码复用和扩展。然而,无限制的继承可能导致代码库变得难以维护,甚至引入安全隐患。为了应对这…...

conda和pip源

conda 地址 ~/.condarc中科大源 channels:- conda-forge- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/- https://mirrors.ustc.edu.cn/anaconda/pkgs/r/- https://mirrors.ustc.edu.cn/anaconda/pkgs/msys2/- defaults show_channel_urls: true查看 conda config --s…...

【c++数学】解一元一次方程

注意&#xff1a;没有合并多项式的功能&#xff0c;且未知数必须只在左边&#xff0c;右边是常数&#xff01;&#xff01;&#xff01; 好用记得点赞&#xff01; 代码如下&#xff1a; #include<iostream> #include<stdio.h>using namespace std;string q,f;d…...

【超详细实战攻略】Jmeter逻辑控制器中if控制器、模块控制器、测试片段的使用方法

【超详细实战攻略】Jmeter逻辑控制器中if控制器、模块控制器、测试片段的使用方法 1 搭建测试对象1.1 禅道下载1.2 禅道安装1.3 运行禅道1.4 接口查看1.5 接口选择 2 Jmeter前置操作2.1 创建Jmeter线程组2.2 创建信息头管理器和请求默认值2.3 添加获取token接口2.4 添加监听器 …...

采用qL-MPC技术进行小型固定翼无人机的路径跟随控制

来自论文"Predictive Path-Following Control for Fixed-Wing UAVs Using the qLMPC Framework in the Presence of Wind Disturbances" 控制架构 采用的是 ULTRA-Extra无人机&#xff0c;相关参数如下&#xff1a; 这里用于guidance law的无人机运动学模型为&#…...