Интегрируй следующую функциональность генерации аудио по команде /audio *тут текст prompt* в код бота Telegram на Python. Я использую Visual Studio Code, и мне нужно, чтобы всё необходимое было в папке с проектом моего кода. Пусть пользователь имеет возможность выбирать язык, пример: /audio ru *prompt тут*.
github https://github.com/suno-ai/bark:
"
from bark import SAMPLE_RATE, generate_audio, preload_models
from IPython.display import Audio

# download and load all models
preload_models()

# generate audio from text
text_prompt = """
     Hello, my name is Suno. And, uh — and I like pizza. [laughs] 
     But I also have other interests such as playing tic tac toe.
"""
audio_array = generate_audio(text_prompt)

# play text in notebook
Audio(audio_array, rate=SAMPLE_RATE)
 pizza.webm 
To save audio_array as a WAV file:

from scipy.io.wavfile import write as write_wav

write_wav("/path/to/audio.wav", SAMPLE_RATE, audio_array)
🌎 Foreign Language
Bark supports various languages out-of-the-box and automatically determines language from input text. When prompted with code-switched text, Bark will attempt to employ the native accent for the respective languages. English quality is best for the time being, and we expect other languages to further improve with scaling.

text_prompt = """
    Buenos días Miguel. Tu colega piensa que tu alemán es extremadamente malo. 
    But I suppose your english isn't terrible.
"""
audio_array = generate_audio(text_prompt)
 miguel.webm 
🎶 Music
Bark can generate all types of audio, and, in principle, doesn't see a difference between speech and music. Sometimes Bark chooses to generate text as music, but you can help it out by adding music notes around your lyrics.

text_prompt = """
    ♪ In the jungle, the mighty jungle, the lion barks tonight ♪
"""
audio_array = generate_audio(text_prompt)
 lion.webm 
🎤 Voice Presets and Voice/Audio Cloning
Bark has the capability to fully clone voices - including tone, pitch, emotion and prosody. The model also attempts to preserve music, ambient noise, etc. from input audio. However, to mitigate misuse of this technology, we limit the audio history prompts to a limited set of Suno-provided, fully synthetic options to choose from for each language. Specify following the pattern: {lang_code}_speaker_{0-9}.

text_prompt = """
    I have a silky smooth voice, and today I will tell you about 
    the exercise regimen of the common sloth.
"""
audio_array = generate_audio(text_prompt, history_prompt="en_speaker_1")
 sloth.webm 
Note: since Bark recognizes languages automatically from input text, it is possible to use for example a german history prompt with english text. This usually leads to english audio with a german accent.

👥 Speaker Prompts
You can provide certain speaker prompts such as NARRATOR, MAN, WOMAN, etc. Please note that these are not always respected, especially if a conflicting audio history prompt is given.

text_prompt = """
    WOMAN: I would like an oatmilk latte please.
    MAN: Wow, that's expensive!
"""
audio_array = generate_audio(text_prompt)
 latte.webm 
💻 Installation
pip install git+https://github.com/suno-ai/bark.git
or

git clone https://github.com/suno-ai/bark
cd bark && pip install . 
🛠️ Hardware and Inference Speed
Bark has been tested and works on both CPU and GPU (pytorch 2.0+, CUDA 11.7 and CUDA 12.0). Running Bark requires running >100M parameter transformer models. On modern GPUs and PyTorch nightly, Bark can generate audio in roughly realtime. On older GPUs, default colab, or CPU, inference time might be 10-100x slower.

If you don't have new hardware available or if you want to play with bigger versions of our models, you can also sign up for early access to our model playground here.

⚙️ Details
Similar to Vall-E and some other amazing work in the field, Bark uses GPT-style models to generate audio from scratch. Different from Vall-E, the initial text prompt is embedded into high-level semantic tokens without the use of phonemes. It can therefore generalize to arbitrary instructions beyond speech that occur in the training data, such as music lyrics, sound effects or other non-speech sounds. A subsequent second model is used to convert the generated semantic tokens into audio codec tokens to generate the full waveform. To enable the community to use Bark via public code we used the fantastic EnCodec codec from Facebook to act as an audio representation.

Below is a list of some known non-speech sounds, but we are finding more every day. Please let us know if you find patterns that work particularly well on Discord!

[laughter]
[laughs]
[sighs]
[music]
[gasps]
[clears throat]
— or ... for hesitations
♪ for song lyrics
capitalization for emphasis of a word
MAN/WOMAN: for bias towards speaker
Supported Languages

Language	Status
English (en)	✅
German (de)	✅
Spanish (es)	✅
French (fr)	✅
Hindi (hi)	✅
Italian (it)	✅
Japanese (ja)	✅
Korean (ko)	✅
Polish (pl)	✅
Portuguese (pt)	✅
Russian (ru)	✅
Turkish (tr)	✅
Chinese, simplified (zh)	✅
 Мой код, куда нужно интегрировать функциональность:
"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')    




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

    executor.start_polling(dp, skip_updates=True)"