Интегрируй следующую функциональность генерации аудио по команде /audio *тут текст prompt* (возможность определять перенос строки и это будут отдельные генерации, как в примере ниже) (также возможность настраивать samples до 3 штук, прим.: /audio 3 *тут текст prompt*. Если цифры после команды /audio нет, то по умолчанию samples = 1) в код бота Telegram на Python:
"github:
Download the TANGO model and generate audio from a text prompt:

import IPython
import soundfile as sf
from tango import Tango

tango = Tango("declare-lab/tango")

prompt = "An audience cheering and clapping"
audio = tango.generate(prompt)
sf.write(f"{prompt}.wav", audio, samplerate=16000)
IPython.display.Audio(data=audio, rate=16000)
 CheerClap.webm 
The model will be automatically downloaded and saved in cache. Subsequent runs will load the model directly from cache.

The generate function uses 100 steps by default to sample from the latent diffusion model. We recommend using 200 steps for generating better quality audios. This comes at the cost of increased run-time.

prompt = "Rolling thunder with lightning strikes"
audio = tango.generate(prompt, steps=200)
IPython.display.Audio(data=audio, rate=16000)
 Thunder.webm 
Use the generate_for_batch function to generate multiple audio samples for a batch of text prompts:

prompts = [
    "A car engine revving",
    "A dog barks and rustles with some clicking",
    "Water flowing and trickling"
]
audios = tango.generate_for_batch(prompts, samples=2)
This will generate two samples for each of the three text prompts.

More generated samples are shown here.

Prerequisites
Our code is built on pytorch version 1.13.1+cu117. We mention torch==1.13.1 in the requirements file but you might need to install a specific cuda version of torch depending on your GPU device type.

Install requirements.txt. You will also need to install the diffusers package from the directory provided in this repo:

git clone https://github.com/declare-lab/tango/
cd tango
pip install -r requirements.txt
cd diffusers
pip install -e ."

Сам код бота:
"import logging
import openai
from aiogram import Bot, Dispatcher, executor, types
from aiogram.utils.exceptions import BadRequest
from aiogram.types import Message, ChatType
import sqlite3
from sqlite3 import Error
from datetime import datetime
from config import *
from ratelimit import limits, sleep_and_retry
import time
import asyncio

openai.api_key = OPENAI_API_KEY 

logging.basicConfig(level=logging.INFO)

bot = Bot(token=TELEGRAM_BOT_TOKEN)
dp = Dispatcher(bot)

def sql_connection():
    try:
        return sqlite3.connect('bot.db')
    except Error:
        print(Error)

def create_messages_table(con):
    try:
        cursorObj = con.cursor()
        cursorObj.execute(
            "CREATE TABLE IF NOT EXISTS messages(id integer PRIMARY KEY, telegram_user_id text, role text, content text, created_at date)")
        con.commit()
    except Error:
        print("Ошибка при работе с SQLite", sqlite3.Error)

# роль по умолчанию (+ изменить в строке 67)
defaultrole = {"role": "system", "content": "Ты - полезный помощник."}

def add_message(con, telegram_user_id, role, message):
    try:
        cursorObj = con.cursor()
 
        cursorObj.execute(f"SELECT COUNT(*) FROM messages WHERE telegram_user_id = '{telegram_user_id}'")
        message_count = cursorObj.fetchone()[0]
        if message_count >= 50:
            cursorObj.execute(f"DELETE FROM messages WHERE telegram_user_id = '{telegram_user_id}' ORDER BY created_at LIMIT 1")
        
        sqlite_insert_query = f"""INSERT INTO messages
                                  (telegram_user_id, role, content, created_at)
                                  VALUES
                                  ('{telegram_user_id}', '{role}', '{message}', '{datetime.now()}');"""
        cursorObj.execute(sqlite_insert_query)
        con.commit()
    except Error:
        print("Ошибка при работе с SQLite", sqlite3.Error)


def delete_user_messages(con, user_id):
    global defaultrole
    try:
        cursorObj = con.cursor()
        cursorObj.execute(
            f"DELETE FROM messages WHERE telegram_user_id = '{user_id}'")
        con.commit()
        # роль по умолчанию
        defaultrole = {"role": "system", "content": "Ты - полезный помощник."}
    except Error:
        print("Ошибка при работе с SQLite", sqlite3.Error)


def get_messages(con, telegram_user_id):
    try:
        cursorObj = con.cursor()
        cursorObj.execute(
            f'SELECT * FROM messages WHERE telegram_user_id = "{telegram_user_id}"')

        return cursorObj.fetchall()
    except Error:
        print("Ошибка при работе с SQLite", sqlite3.Error)


@limits(calls=5, period=60)
@sleep_and_retry
async def ai(prompt, user_id):
    global defaultrole

    try:
        await asyncio.sleep(1)
        messages = [
            defaultrole,
        ]

        user_messages = get_messages(db, user_id)
        for message in user_messages:
            messages.append({"role": message[2], "content": message[3]})

        messages.append({"role": "user", "content": prompt})

        completion = openai.ChatCompletion.create(
            model="gpt-3.5-turbo",
            messages=messages,
        )

        add_message(db, user_id, 'user', prompt)
        add_message(db, user_id, 'assistant', completion.choices[0].message.content)

        return completion.choices[0].message.content
    except:
        return None


@dp.message_handler(commands=['role'])
async def set_role(message: types.Message):
  global defaultrole

  received_text = message.text.replace('/role ','')
  
  if received_text.strip() == '':
    await bot.send_message(message.chat.id, "Введите текст после команды /role")
    return
  delete_user_messages(db, message.from_user.id)
  defaultrole = {"role": "system", "content": received_text.strip()}
  await bot.send_message(message.chat.id, f"Роль изменена:\n{received_text}")


@dp.message_handler(commands=['clear'])
async def send_welcome(message: types.Message):
    delete_user_messages(db, message.from_user.id)

    await message.reply("История очищена")


@dp.message_handler(commands=['gpt'])
async def echo(message: types.Message):

    answer = await ai(message.text[4:], message.from_user.id)

    if answer != None:
        await message.reply(answer)
        print(get_messages(db, message.from_user.id))
    else:
        await message.reply('Произошла ошибка, очистите историю: /clear')    

@limits(calls=10, period=60)
@sleep_and_retry
@dp.message_handler(commands=['img'])
async def generate_image(message: types.Message):
    prompt_text = message.text.replace("/img", "")
    
    if not prompt_text:
        await bot.send_message(chat_id=message.chat.id, text="Введите текст")
        return

    try:
        # Создаем изображение на основе текста пользователя
        result = openai.Image.create(
            prompt=prompt_text,
            n=1,
            size='256x256'
        )
    except Exception as e:
        await bot.send_message(chat_id=message.chat.id, text="Ошибка при генерации изображения :(")
        return
    
    # Отправляем пользователю сгенерированное изображение
    try:
        await bot.send_photo(chat_id=message.chat.id, photo=result['data'][0]['url'])
    except BadRequest:
        await bot.send_message(chat_id=message.chat.id, text="Не удалось отправить изображение :(")


@dp.message_handler()
async def message_handler(message: types.Message):
    if message.chat.type == ChatType.PRIVATE:

        answer = await ai(message.text, message.from_user.id)

        if answer != None:
            await message.reply(answer)
            print(get_messages(db, message.from_user.id))
        else:
            await message.reply('Произошла ошибка, очистите историю: /clear')


if __name__ == '__main__':
    db = sql_connection()
    create_messages_table(db)

    executor.start_polling(dp, skip_updates=True)"