在实时语音交互上超过GPT-4o,端到端语音模型Mini-Omni部署

news2024/9/27 8:08:45

Mini-Omni是清华大学开源的多模态大型语言模型,具备实时语音输入和流式音频输出的能力。

Mini-Omni模型能够一边听、一边说,一边思考,类似于ChatGPT的语言对话模式。

Mini-Omni模型的主要特点是能够直接通过音频模态进行推理,并生成流式输出,而不需要依赖额外的文本到语音(TTS)系统,从而减少了延迟。

Mini-Omni模型的架构在Qwen2-0.5B基础上进行了增强,使用了Whisper-small编码器来有效处理语音输入。

Mini-Omni模型采用了并行文本-音频生成方法,通过批量并行解码生成语音和文本,确保了模型在不同模态间的推理能力不受损害。

Mini-Omni模型还引入了VoiceAssistant-400K数据集,用于对优化语音输出的模型进行微调。

github项目地址:https://github.com/gpt-omni/mini-omni。

一、环境安装

1、python环境

建议安装python版本在3.10以上。

2、pip库安装

pip install torch==2.3.1+cu118 torchvision==0.18.1+cu118 torchaudio==2.3.1 --extra-index-url https://download.pytorch.org/whl/cu118

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

3、模型下载

git lfs install

git clone https://huggingface.co/gpt-omni/mini-omni

、功能测试

1、运行测试

(1)python代码调用测试

import os
import torch
import time
import lightning as L
import soundfile as sf
import whisper
from snac import SNAC
from litgpt import Tokenizer
from tqdm import tqdm
from huggingface_hub import snapshot_download
from lightning.fabric.utilities.load import _lazy_load as lazy_load
from utils.snac_utils import layershift, reconscruct_snac, reconstruct_tensors, get_time_str, get_snac, generate_audio_data
from litgpt.utils import num_parameters
from litgpt.generate.base import generate_AA, generate_ASR, generate_TA, generate_TT, generate_AT, generate_TA_BATCH, next_token_batch
from litgpt.model import GPT, Config


torch.set_printoptions(sci_mode=False)


# Constants Definitions
text_vocabsize = 151936
text_specialtokens = 64
audio_vocabsize = 4096
audio_specialtokens = 64

padded_text_vocabsize = text_vocabsize + text_specialtokens
padded_audio_vocabsize = audio_vocabsize + audio_specialtokens

_eot = text_vocabsize
_pad_t = text_vocabsize + 1
_input_t = text_vocabsize + 2
_answer_t = text_vocabsize + 3
_asr = text_vocabsize + 4

_eoa = audio_vocabsize
_pad_a = audio_vocabsize + 1
_input_a = audio_vocabsize + 2
_answer_a = audio_vocabsize + 3
_split = audio_vocabsize + 4


# Utility Functions
def get_input_ids_TA(text, text_tokenizer):
    input_ids_item = [[] for _ in range(8)]
    text_tokens = text_tokenizer.encode(text)
    for i in range(7):
        input_ids_item[i] = [layershift(_pad_a, i)] * (len(text_tokens) + 2) + [
            layershift(_answer_a, i)
        ]
        input_ids_item[i] = torch.tensor(input_ids_item[i]).unsqueeze(0)
    input_ids_item[-1] = [_input_t] + text_tokens.tolist() + [_eot] + [_answer_t]
    input_ids_item[-1] = torch.tensor(input_ids_item[-1]).unsqueeze(0)
    return input_ids_item


def get_input_ids_TT(text, text_tokenizer):
    input_ids_item = [[] for i in range(8)]
    text_tokens = text_tokenizer.encode(text).tolist()
    for i in range(7):
        input_ids_item[i] = torch.tensor(
            [layershift(_pad_a, i)] * (len(text_tokens) + 3)
        ).unsqueeze(0)
    input_ids_item[-1] = [_input_t] + text_tokens + [_eot] + [_answer_t]
    input_ids_item[-1] = torch.tensor(input_ids_item[-1]).unsqueeze(0)
    return input_ids_item


def get_input_ids_whisper(mel, leng, whispermodel, device, 
                          special_token_a=_answer_a, special_token_t=_answer_t):
    with torch.no_grad():
        mel = mel.unsqueeze(0).to(device)
        audio_feature = whispermodel.embed_audio(mel)[0][:leng]

    T = audio_feature.size(0)
    input_ids = []
    for i in range(7):
        input_ids_item = []
        input_ids_item.append(layershift(_input_a, i))
        input_ids_item += [layershift(_pad_a, i)] * T
        input_ids_item += [(layershift(_eoa, i)), layershift(special_token_a, i)]
        input_ids.append(torch.tensor(input_ids_item).unsqueeze(0))
    input_id_T = torch.tensor([_input_t] + [_pad_t] * T + [_eot, special_token_t])
    input_ids.append(input_id_T.unsqueeze(0))
    return audio_feature.unsqueeze(0), input_ids


def get_input_ids_whisper_ATBatch(mel, leng, whispermodel, device):
    with torch.no_grad():
        mel = mel.unsqueeze(0).to(device)
        audio_feature = whispermodel.embed_audio(mel)[0][:leng]
    
    T = audio_feature.size(0)

    input_ids_AA, input_ids_AT = [], []
    for i in range(7):
        lang_shift = layershift(_pad_a, i)
        input_ids_item_AA = [layershift(_input_a, i)] + [lang_shift] * T + [(layershift(_eoa, i)), layershift(_answer_a, i)]
        input_ids_item_AT = [layershift(_input_a, i)] + [lang_shift] * T + [(layershift(_eoa, i)), lang_shift]
        input_ids_AA.append(torch.tensor(input_ids_item_AA))
        input_ids_AT.append(torch.tensor(input_ids_item_AT))

    input_id_T = torch.tensor([_input_t] + [_pad_t] * T + [_eot, _answer_t])
    input_ids_AA.append(input_id_T)
    input_ids_AT.append(input_id_T)

    return torch.stack([audio_feature, audio_feature]), [input_ids_AA, input_ids_AT]


def load_audio(path):
    audio = whisper.load_audio(path)
    duration_ms = (len(audio) / 16000) * 1000
    audio = whisper.pad_or_trim(audio)
    mel = whisper.log_mel_spectrogram(audio)
    return mel, int(duration_ms / 20) + 1


def model_inference(fabric, model, snacmodel, tokenizer, func, step, *args, **kwargs):
    with fabric.init_tensor():
        model.set_kv_cache(batch_size=1)
    output = func(fabric, *args, **kwargs)
    model.clear_kv_cache()
    return output


def load_model(ckpt_dir, device):
    snacmodel = SNAC.from_pretrained("hubertsiuzdak/snac_24khz").eval().to(device)
    whispermodel = whisper.load_model("small").to(device)
    text_tokenizer = Tokenizer(ckpt_dir)
    fabric = L.Fabric(devices=1, strategy="auto")
    config = Config.from_file(ckpt_dir + "/model_config.yaml")
    config.post_adapter = False

    with fabric.init_module(empty_init=False):
        model = GPT(config)

    model = fabric.setup(model)
    state_dict = lazy_load(ckpt_dir + "/lit_model.pth")
    model.load_state_dict(state_dict, strict=True)
    model.to(device).eval()

    return fabric, model, text_tokenizer, snacmodel, whispermodel


def download_model(ckpt_dir):
    repo_id = "gpt-omni/mini-omni"
    snapshot_download(repo_id, local_dir=ckpt_dir, revision="main")


class OmniInference:

    def __init__(self, ckpt_dir='checkpoint', device='cuda'):
        self.device = device
        if not os.path.exists(ckpt_dir):
            print(f"Checkpoint directory {ckpt_dir} not found, downloading from huggingface")
            download_model(ckpt_dir)
        self.fabric, self.model, self.text_tokenizer, self.snacmodel, self.whispermodel = load_model(ckpt_dir, device)

    def warm_up(self, sample='./data/samples/output1.wav'):
        for _ in self.run_AT_batch_stream(sample):
            pass

    @torch.inference_mode()
    def run_AT_batch_stream(self, audio_path, stream_stride=4, max_returned_tokens=2048, temperature=0.9, top_k=1, top_p=1.0, eos_id_a=_eoa, eos_id_t=_eot):
        assert os.path.exists(audio_path), f"Audio file {audio_path} not found"

        with self.fabric.init_tensor():
            self.model.set_kv_cache(batch_size=2)

        mel, leng = load_audio(audio_path)
        audio_feature, input_ids = get_input_ids_whisper_ATBatch(mel, leng, self.whispermodel, self.device)
        T = input_ids[0].size(1)
        device = input_ids[0].device

        assert max_returned_tokens > T, f"Max returned tokens {max_returned_tokens} should be greater than audio length {T}"
        if self.model.max_seq_length < max_returned_tokens - 1:
            raise NotImplementedError(f"max_seq_length {self.model.max_seq_length} needs to be >= {max_returned_tokens - 1}")

        input_pos = torch.tensor([T], device=device)
        list_output = [[] for _ in range(8)]
        tokens_A, token_T = next_token_batch(
            self.model,
            audio_feature.to(torch.float32).to(self.model.device),
            input_ids,
            [T - 3, T - 3],
            ["A1T2", "A1T2"],
            input_pos=torch.arange(0, T, device=device),
            temperature=temperature,
            top_k=top_k,
            top_p=top_p,
        )

        for i in range(7):
            list_output[i].append(tokens_A[i].tolist()[0])
        list_output[7].append(token_T.tolist()[0])

        model_input_ids = [[] for _ in range(8)]
        for i in range(7):
            tokens_A[i] = tokens_A[i].clone() + padded_text_vocabsize + i * padded_audio_vocabsize
            model_input_ids[i].append(tokens_A[i].clone().to(device).to(torch.int32))
            model_input_ids[i].append(torch.tensor([layershift(4097, i)], device=device))
            model_input_ids[i] = torch.stack(model_input_ids[i])

        model_input_ids[-1].append(token_T.clone().to(torch.int32))
        model_input_ids[-1].append(token_T.clone().to(torch.int32))
        model_input_ids[-1] = torch.stack(model_input_ids[-1])

        text_end = False
        index = 1
        nums_generate = stream_stride
        begin_generate = False
        current_index = 0

        for _ in tqdm(range(2, max_returned_tokens - T + 1)):
            tokens_A, token_T = next_token_batch(
                self.model, None, model_input_ids, None, None, input_pos=input_pos, temperature=temperature, top_k=top_k, top_p=top_p
            )

            if text_end:
                token_T = torch.tensor([_pad_t], device=device)
            if tokens_A[-1] == eos_id_a:
                break
            if token_T == eos_id_t:
                text_end = True

            for i in range(7):
                list_output[i].append(tokens_A[i].tolist()[0])
            list_output[7].append(token_T.tolist()[0])

            model_input_ids = [[] for _ in range(8)]
            for i in range(7):
                tokens_A[i] = tokens_A[i].clone() + padded_text_vocabsize + i * padded_audio_vocabsize
                model_input_ids[i].append(tokens_A[i].clone().to(device).to(torch.int32))
                model_input_ids[i].append(torch.tensor([layershift(4097, i)], device=device))
                model_input_ids[i] = torch.stack(model_input_ids[i])

            model_input_ids[-1].append(token_T.clone().to(torch.int32))
            model_input_ids[-1].append(token_T.clone().to(torch.int32))
            model_input_ids[-1] = torch.stack(model_input_ids[-1])

            if index == 7:
                begin_generate = True
            if begin_generate:
                current_index += 1
                if current_index == nums_generate:
                    current_index = 0
                    snac = get_snac(list_output, index, nums_generate)
                    audio_stream = generate_audio_data(snac, self.snacmodel)
                    yield audio_stream

            input_pos = input_pos.add_(1)
            index += 1
        
        text = self.text_tokenizer.decode(torch.tensor(list_output[-1]))
        print(f"Text output: {text}")
        self.model.clear_kv_cache()
        return list_output


def test_infer():
    device = "cuda:0"
    out_dir = f"./output/{get_time_str()}"
    ckpt_dir = f"./checkpoint"
    if not os.path.exists(ckpt_dir):
        print(f"Checkpoint directory {ckpt_dir} not found, downloading from huggingface")
        download_model(ckpt_dir)

    fabric, model, text_tokenizer, snacmodel, whispermodel = load_model(ckpt_dir, device)
    task = ['A1A2', 'asr', "T1A2", "AA-BATCH", 'T1T2', 'AT']

    # Prepare test data
    test_audio_list = sorted(os.listdir('./data/samples'))
    test_audio_list = [os.path.join('./data/samples', path) for path in test_audio_list]
    test_audio_transcripts = [
        "What is your name?",
        "What are your hobbies?",
        "Do you like Beijing?",
        "How are you feeling today?",
        "What is the weather like today?"
    ]
    test_text_list = [
        "What is your name?",
        "How are you feeling today?",
        "Can you describe your surroundings?",
        "What did you do yesterday?",
        "What is your favorite book and why?",
        "How do you make a cup of tea?",
        "What is the weather like today?",
        "Can you explain the concept of time?",
        "Can you tell me a joke?"
    ]

    with torch.no_grad():
        for task_name in task:
            if "A1A2" in task_name:
                print("===============================================================")
                print("                       Testing A1A2")
                print("===============================================================")
                for i, path in enumerate(test_audio_list):
                    try:
                        mel, leng = load_audio(path)
                        audio_feature, input_ids = get_input_ids_whisper(mel, leng, whispermodel, device)
                        text = model_inference(fabric, model, snacmodel, text_tokenizer, A1_A2, i,
                                               fabric, audio_feature, input_ids, leng, model, text_tokenizer, i, snacmodel, out_dir)
                        print(f"Input: {test_audio_transcripts[i]}")
                        print(f"Output: {text}")
                        print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                    except Exception as e:
                        print(f"[Error] Failed to process {path}: {e}")
                print("===============================================================")

            if 'asr' in task_name:
                print("===============================================================")
                print("                       Testing ASR")
                print("===============================================================")

                for i, path in enumerate(test_audio_list):
                    mel, leng = load_audio(path)
                    audio_feature, input_ids = get_input_ids_whisper(mel, leng, whispermodel, device, special_token_a=_pad_a, special_token_t=_asr)
                    output = model_inference(fabric, model, snacmodel, text_tokenizer, A1_T1, i,
                                             fabric, audio_feature, input_ids, leng, model, text_tokenizer, i).lower().replace(',', '').replace('.', '').replace('?', '')
                    print(f"Audio path: {path}")
                    print(f"Audio transcript: {test_audio_transcripts[i]}")
                    print(f"ASR output: {output}")
                    print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                print("===============================================================")

            if "T1A2" in task_name:
                print("===============================================================")
                print("                       Testing T1A2")
                print("===============================================================")
                for i, text in enumerate(test_text_list):
                    input_ids = get_input_ids_TA(text, text_tokenizer)
                    text_output = model_inference(fabric, model, snacmodel, text_tokenizer, T1_A2, i,
                                                  fabric, input_ids, model, text_tokenizer, i, snacmodel, out_dir)
                    print(f"Input: {text}")
                    print(f"Output: {text_output}")
                    print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                print("===============================================================")

            if "T1T2" in task_name:
                print("===============================================================")
                print("                       Testing T1T2")
                print("===============================================================")
                for i, text in enumerate(test_text_list):
                    input_ids = get_input_ids_TT(text, text_tokenizer)
                    text_output = model_inference(fabric, model, snacmodel, text_tokenizer, T1_T2, i,
                                                  fabric, input_ids, model, text_tokenizer, i)
                    print(f"Input: {text}")
                    print(f"Output: {text_output}")
                    print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                print("===============================================================")

            if "AT" in task_name:
                print("===============================================================")
                print("                       Testing A1T2")
                print("===============================================================")
                for i, path in enumerate(test_audio_list):
                    mel, leng = load_audio(path)
                    audio_feature, input_ids = get_input_ids_whisper(mel, leng, whispermodel, device, special_token_a=_pad_a, special_token_t=_answer_t)
                    text = model_inference(fabric, model, snacmodel, text_tokenizer, A1_T2, i,
                                           fabric, audio_feature, input_ids, leng, model, text_tokenizer, i)
                    print(f"Input: {test_audio_transcripts[i]}")
                    print(f"Output: {text}")
                    print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                print("===============================================================")

            if "AA-BATCH" in task_name:
                print("===============================================================")
                print("                       Testing A1A2-BATCH")
                print("===============================================================")
                for i, path in enumerate(test_audio_list):
                    mel, leng = load_audio(path)
                    audio_feature, input_ids = get_input_ids_whisper_ATBatch(mel, leng, whispermodel, device)
                    text = model_inference(fabric, model, snacmodel, text_tokenizer, A1_A2_batch, i,
                                           fabric, audio_feature, input_ids, leng, model, text_tokenizer, i, snacmodel, out_dir)
                    print(f"Input: {test_audio_transcripts[i]}")
                    print(f"Output: {text}")
                    print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                print("===============================================================")

        print("========================= Test End ============================")


if __name__ == "__main__":
    test_infer()

未完......

更多详细的欢迎关注:杰哥新技术

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2169412.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

python全栈学习记录(十六)模块与包

模块与包 文章目录 模块与包一、模块1.模块的导入方式2.模块的循环导入问题3.搜索路径与优先级 二、包1.包的使用2.绝对导入与相对导入 三、一般工程的开发目录规范 一、模块 模块是一系列功能的集合体&#xff0c;常见的模块形式&#xff08;自定义模块、第三方模块、内置模块…

重头开始嵌入式第四十三天(硬件 ARM架构 汇编语言)

目录 ARM架构补充 一&#xff0c;程序状态寄存器 二&#xff0c;处理器工作模式 三&#xff0c;异常处理 四&#xff0c;指令流水线 汇编语言 一&#xff0c;什么是汇编 二&#xff0c;汇编怎么编 三&#xff0c;ARM汇编指令集 四&#xff0c;数据处理指令 五&#…

DC00019基于java swing+sqlserver超市商品信息管理系统java项目GUI商品信息管理系统

1、项目功能演示 DC00019基于java swingsqlserver超市商品信息管理系统java项目GUI商品信息管理系统 2、项目功能描述 基于java swingsqlserver超市管理系统功能 1、系统登录 2、员工管理&#xff1a;添加员工、查询员工、所有员工 3、部门管理&#xff1a;添加部门、查询部门…

数据结构 ——— 移除元素(快慢指针)

目录 题目要求 代码实现&#xff08;快慢指针&#xff09; 题目要求 编写函数&#xff0c;给你一个数组 nums 和一个值 val&#xff0c;你需要在 nums 数组 原地 移除所有数值等于 val 的元素&#xff0c;并且返回移除后数组的新长度 不能使用额外的数组空间&#xff0c;要…

SSM的学习(3)

项目的结构: 如下图所示。 对SqlMapConfig.xml的分析&#xff1a; 是主要的配置文件。里面写的是 数据的配置 1:引入jdbc.properties 这个里面写的是 账号和密码等信息&#xff0c;不在写在xml里面了&#xff0c;防止写死! 用的是<properties resource "这个外部…

将图片资源保存到服务器的盘符中

服务类 系统盘符&#xff1a;file-path.disk&#xff08;可能会变&#xff0c;配置配置文件dev中&#xff09;文件根路径&#xff1a;file-path.root-path&#xff08;可能会变&#xff0c;配置配置文件dev中&#xff09;http协议的Nginx的映射前缀&#xff1a;PrefixConstant.…

__问题——解决CLion开发Linux驱动时显示头文件缺失

问题描述&#xff1a; 在使用CLion开发Linux驱动时&#xff0c;需要引入各种头文件&#xff0c;比如<linux/module>、<linux/init>等&#xff0c;但是毫无例外&#xff0c;都会在报错提示文件或文件路径不存在。这在很大程度上限制了CLion的发挥&#xff0c;因为无…

【linux】gdb

&#x1f525;个人主页&#xff1a;Quitecoder &#x1f525;专栏&#xff1a;linux笔记仓 目录 01.gdb使用 01.gdb使用 程序的发布方式有两种&#xff0c;debug模式和release模式Linux gcc/g出来的二进制程序&#xff0c;默认是release模式要使用gdb调试&#xff0c;必须在源…

c语言200例 063 信息查询

大家好&#xff0c;欢迎来到无限大的频道。 今天给大家带来的是c语言200例 题目要求&#xff1a; 从键盘当中输入姓名和电话号&#xff0c;以“#”结束&#xff0c;编程实现输入姓名、查询电话号的功能。 参考代码如下&#xff1a; #include <stdio.h> #include <st…

1.6 判定表

欢迎大家订阅【软件测试】 专栏&#xff0c;开启你的软件测试学习之旅&#xff01; 文章目录 1 基本概念1.1 作用1.2 优点 2 基本组成2.1 条件桩2.2 动作桩2.3 条件项2.4 动作项 3 判定表的结构与规则3.1 规则的生成3.2 动作结果3.3 判定表简化 4 判定表的使用场景4.1 软件测试…

什么是Node.js?

为什么JavaScript可以在浏览器中被执行&#xff1f; 在浏览器中我们加载了一些待执行JS代码&#xff0c;这些字符串要当中一个代码去执行&#xff0c;是因为浏览器中有JavaScript的解析引擎&#xff0c;它的存在我们的代码才能被执行。 不同的浏览器使用不同的javaScript解析引…

Linux 文件目录结构(详细)

一、基本介绍 Linux的文件系统是采用级层式的树状目录结构&#xff0c;在此结构中的最上层是根目录“/”&#xff0c;然后在此目录下再创建其他的目录。 Linux世界中&#xff0c;一切皆文件&#xff01; 二、相关目录 /bin[常用](/usr/bin、/usr/local/bin) 是Binary的缩写,…

RabbitMQ常用管理命令及管理后台

RabbitMQ管理命令 1、用户管理1.1、新增一个用户1.2、查看当前用户列表1.3、设置用户角色1.4、设置用户权限1.5、查看用户权限 2、RabbitMQ的web管理后台2.1、查看rabbitmq 的插件列表2.2、启用插件2.3、禁用插件2.4、访问RabbitMQ的web后台2.4、通过web页面新建虚拟主机 ./rab…

LLM - 使用 vLLM 部署 Qwen2-VL 多模态大模型 (配置 FlashAttention) 教程

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://spike.blog.csdn.net/article/details/142528967 免责声明&#xff1a;本文来源于个人知识与公开资料&#xff0c;仅用于学术交流&#xff0c;欢迎讨论&#xff0c;不支持转载。 vLLM 用…

虚拟机开启网络代理设置,利用主机代理访问国外资源

前言 有时候需要访问一些镜像网站拉取安装包或是学习资料&#xff0c;由于国内外网络环境差异和网络安全的问题&#xff0c;总会被阻拦。下文来说一下虚拟机centos7如何通过连接主机的代理软件。 一、代理软件设置 1、前提是主机要安装有代理软件&#xff0c;查看代理软件的…

LabVIEW提高开发效率技巧----并行处理

在LabVIEW开发中&#xff0c;充分利用并行处理能力可以显著提高程序的执行效率和响应速度。LabVIEW的图形化编程模型天然支持并行任务的执行&#xff0c;可以通过以下几种方式优化程序性能。 1. 并行For循环&#xff08;Parallel For Loop&#xff09; 对于能够独立执行的任务…

开源鸿蒙OpenHarmony系统更换开机Logo方法,瑞芯微RK3566鸿蒙开发板

本文适用于开源鸿蒙OpenHarmony系统更换开机Logo&#xff0c;本次使用的是触觉智能的Purple Pi OH鸿蒙开源主板&#xff0c;搭载了瑞芯微RK3566芯片&#xff0c;类树莓派设计&#xff0c;是Laval官方社区主荐的一款鸿蒙开发主板。 介绍 OpenHarmony的品牌标志、版本信息、项目…

RabbitMQ 高级特性——重试机制

文章目录 前言重试机制配置文件设置生命交换机、队列和绑定关系生产者发送消息消费消息 前言 前面我们学习了 RabbitMQ 保证消息传递可靠性的机制——消息确认、持久化和发送发确认&#xff0c;那么对于消息确认和发送方确认&#xff0c;如果接收方没有收到消息&#xff0c;那…

每日一题:⻓度最⼩的⼦数组

文章目录 一、题目二、解析1、暴力算法&#xff08;1&#xff09;纯暴力&#xff08;2&#xff09;前缀和 循环 2、滑动窗口 一、题目 209. 长度最小的子数组 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 子数组…

Java项目实战II基于Java+Spring Boot+MySQL的IT技术交流和分享平台的设计与实现(源码+数据库+文档)

目录 一、前言 二、技术介绍 三、系统实现 四、文档参考 五、核心代码 六、源码获取 全栈码农以及毕业设计实战开发&#xff0c;CSDN平台Java领域新星创作者&#xff0c;专注于大学生项目实战开发、讲解和毕业答疑辅导。获取源码联系方式请查看文末 一、前言 在当今信息…