Уведомления

Группа в Telegram: @pythonsu

#1 Фев. 12, 2023 22:33:54

Genabox
Зарегистрирован: 2022-12-24
Сообщения: 198
Репутация: +  1  -
Профиль   Отправить e-mail  

import whisper error

 import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
import whisper
from tts import tts
from parse_statement import parse
load_dotenv()
intents = discord.Intents.all()
client = commands.Bot(command_prefix="&", intents=intents)
# model = whisper.load_model("base")
model = whisper.load_model("small")
# join vc
@client.command()
async def join(ctx):
    if ctx.author.voice:
        channel = ctx.message.author.voice.channel
        await channel.connect()
    else:
        await ctx.send("not in a voice channel!")
# leave vc
@client.command()
async def leave(ctx):
    if ctx.voice_client:
        await ctx.voice_client.disconnect()
    else:
        await ctx.send("not in a voice channel!")
# play tts audio from command
@client.command()
async def play(ctx, *, arg):
    tts(ctx, arg)
@client.command()
async def listen(ctx):
    if ctx.voice_client:
        ctx.voice_client.start_recording(discord.sinks.WaveSink(), callback, ctx)
        await ctx.send("listening...")
    else:
        await ctx.send("not in a voice channel!")
async def callback(sink: discord.sinks, ctx):
    for user_id, audio in sink.audio_data.items():
        if user_id == ctx.author.id:
            audio: discord.sinks.core.AudioData = audio
            print(user_id)
            filename = "audio.wav"
            with open(filename, "wb") as f:
                f.write(audio.file.getvalue())
            text = model.transcribe(filename)["text"]
            os.remove(filename)
            print(f"Received from {ctx.author.name}: {text}")
            reply = parse(text)
            print(f"Reply: {reply}")
            tts(ctx, reply)
# stops recording
@client.command()
async def stop(ctx):
    ctx.voice_client.stop_recording()
@client.event
async def on_ready():
    print(f"We have logged in as {client.user}")
@client.event
async def on_message(message):
    await client.process_commands(message)
    if message.author == client.user:
        return
    # ping
    if message.content.startswith("ping"):
        await message.channel.send("pong")
client.run(os.environ.get("DISCORD"))


(discord) PS D:\discord> & CUsers/Gena/.virtualenvs/discord-q4ERoUCO/Scripts/python.exe ddiscord/package/test/bot.py
Traceback (most recent call last):
File “d:\discord\package\test\bot.py”, line 7, in <module>
import whisper
File “C:\Users\Gena\.virtualenvs\discord-q4ERoUCO\lib\site-packages\whisper.py”, line 69, in <module>
libc = ctypes.CDLL(libc_name)
File “C:\Users\Gena\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py”, line 364, in __init__
if ‘/’ in name or ‘\\’ in name:
TypeError: argument of type ‘NoneType’ is not iterable
(discord) PS D:\discord>

подскажите что с этим делать
полный исходник
https://github.com/sergmister/Discord-VC-Bot

Отредактировано Genabox (Фев. 12, 2023 22:34:34)

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version