add reqect all user message
This commit is contained in:
+49
-70
@@ -1,7 +1,3 @@
|
||||
import subprocess
|
||||
import speech_recognition as sr
|
||||
import os
|
||||
from functions.loging import loging
|
||||
import requests
|
||||
|
||||
|
||||
@@ -22,71 +18,54 @@ class Converter:
|
||||
|
||||
:return: str - текст + служебная информация
|
||||
"""
|
||||
# f = -1.0
|
||||
try:
|
||||
r = requests.get("http://192.168.0.108:5000/ping")
|
||||
if r.status_code == 200:
|
||||
response = requests.post("http://192.168.0.108:5000/decrypt_audio",
|
||||
files={"file": open(self.path_to_file, "rb").read()})
|
||||
if response.status_code == 200:
|
||||
return f"От компа:\n{response.text.replace('"', '')}"
|
||||
else:
|
||||
return 'Не удалось получить текст.'
|
||||
r = requests.get("http://192.168.0.108:5000/ping")
|
||||
if r.status_code == 200:
|
||||
response = requests.post("http://192.168.0.108:5000/decrypt_audio",
|
||||
files={"file": open(self.path_to_file, "rb").read()})
|
||||
if response.status_code == 200:
|
||||
return f"От компа:\n{response.text}"
|
||||
else:
|
||||
result = self.model.transcribe(self.path_to_file)
|
||||
return result["text"]
|
||||
# try:
|
||||
# import mutagen
|
||||
# f = mutagen.File(self.path_to_file) # получение данных mutagen
|
||||
# f = float(f.info.length)
|
||||
# if f >= 30.0: # если длинна больше 30 секунд
|
||||
# self.service = "google" # устанавливаю сервис google
|
||||
# return self.google(f) # запуск функции google
|
||||
# else:
|
||||
# self.service = "yandex" # устанавливаем сервис yandex
|
||||
# return self.yandex(f) # запуск функции yandex
|
||||
# except Exception as e: # если какая-то проблема
|
||||
# print(e)
|
||||
# return self.google(f) # запуск функции google
|
||||
except sr.RequestError: # обработка ошибки размера файлов
|
||||
return "Толи файл слишком большой, толи с ботом что-то случилось" # возвращение ошибки
|
||||
return 'Не удалось получить текст.'
|
||||
else:
|
||||
result = self.model.transcribe(self.path_to_file)
|
||||
return result["text"]
|
||||
|
||||
def google(self, f) -> str:
|
||||
"""
|
||||
Функция работающая с stt google
|
||||
|
||||
:return: str - текст + служебная информация
|
||||
"""
|
||||
subprocess.run(['ffmpeg', '-v', 'quiet', '-i', self.path_to_file, self.path_to_file.replace(".ogg", ".wav")])
|
||||
# перевод ogg в wav
|
||||
try:
|
||||
os.remove(self.path_to_file) # удаляю файл
|
||||
wav_file = self.path_to_file.replace(".ogg", ".wav") # замена в ссылке на файл ogg в wav
|
||||
r = sr.Recognizer() # создаю объект google stt
|
||||
with sr.AudioFile(wav_file) as source: # получаю байты из файла
|
||||
audio = r.record(source) # получаю файл в нужном google stt формате байт
|
||||
r.adjust_for_ambient_noise(source) # мини очистка шума
|
||||
try:
|
||||
response = "google\n\n" + r.recognize_google(audio, language=self.language) # получение текста
|
||||
loging(self.message, "google", wav_file, response, f) # записываю логи
|
||||
os.remove(wav_file) # удаляю лишние файлы
|
||||
return response # возвращаю текст
|
||||
except sr.UnknownValueError: # ошибка распознавания текста
|
||||
return "google\n\n Слова не распознаны, вы что вообще мне впихнуть пытаетесь" # возвращаю ошибочное
|
||||
# сообщение
|
||||
except FileNotFoundError: # ошибка файла(из-за веса telegram не пускает)
|
||||
return "Толи файл слишком большой, толи с ботом что-то случилось" # возвращение ошибки
|
||||
|
||||
def yandex(self, f) -> str:
|
||||
"""
|
||||
Функция работающая с stt yandex
|
||||
|
||||
:return: str - текст + служебная информация
|
||||
"""
|
||||
from speechkit import ShortAudioRecognition, Session # импортирую сесию и объект для stt
|
||||
reg = ShortAudioRecognition(Session.from_api_key("AQVN3xNJamAFP4_FS6Gis0Uud0vONFk24umBSXvh")) # получаю
|
||||
# объект для расшифровки
|
||||
response = "yandex\n\n" + reg.recognize(open(str(self.path_to_file), str('rb')).read()) # получаю весь текст
|
||||
loging(self.message, "yandex", self.path_to_file, response, f) # записываю логи
|
||||
os.remove(self.path_to_file) # удаляю лишние файлы
|
||||
return response # возвращаю ответ
|
||||
# def google(self, f) -> str:
|
||||
# """
|
||||
# Функция работающая с stt google
|
||||
#
|
||||
# :return: str - текст + служебная информация
|
||||
# """
|
||||
# subprocess.run(['ffmpeg', '-v', 'quiet', '-i', self.path_to_file, self.path_to_file.replace(".ogg", ".wav")])
|
||||
# # перевод ogg в wav
|
||||
# try:
|
||||
# os.remove(self.path_to_file) # удаляю файл
|
||||
# wav_file = self.path_to_file.replace(".ogg", ".wav") # замена в ссылке на файл ogg в wav
|
||||
# r = sr.Recognizer() # создаю объект google stt
|
||||
# with sr.AudioFile(wav_file) as source: # получаю байты из файла
|
||||
# audio = r.record(source) # получаю файл в нужном google stt формате байт
|
||||
# r.adjust_for_ambient_noise(source) # мини очистка шума
|
||||
# try:
|
||||
# response = "google\n\n" + r.recognize_google(audio, language=self.language) # получение текста
|
||||
# loging(self.message, "google", wav_file, response, f) # записываю логи
|
||||
# os.remove(wav_file) # удаляю лишние файлы
|
||||
# return response # возвращаю текст
|
||||
# except sr.UnknownValueError: # ошибка распознавания текста
|
||||
# return "google\n\n Слова не распознаны, вы что вообще мне впихнуть пытаетесь" # возвращаю ошибочное
|
||||
# # сообщение
|
||||
# except FileNotFoundError: # ошибка файла(из-за веса telegram не пускает)
|
||||
# return "Толи файл слишком большой, толи с ботом что-то случилось" # возвращение ошибки
|
||||
#
|
||||
# def yandex(self, f) -> str:
|
||||
# """
|
||||
# Функция работающая с stt yandex
|
||||
#
|
||||
# :return: str - текст + служебная информация
|
||||
# """
|
||||
# from speechkit import ShortAudioRecognition, Session # импортирую сесию и объект для stt
|
||||
# reg = ShortAudioRecognition(Session.from_api_key("AQVN3xNJamAFP4_FS6Gis0Uud0vONFk24umBSXvh")) # получаю
|
||||
# # объект для расшифровки
|
||||
# response = "yandex\n\n" + reg.recognize(open(str(self.path_to_file), str('rb')).read()) # получаю весь текст
|
||||
# loging(self.message, "yandex", self.path_to_file, response, f) # записываю логи
|
||||
# os.remove(self.path_to_file) # удаляю лишние файлы
|
||||
# return response # возвращаю ответ
|
||||
|
||||
+17
-1
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from aiogram.utils import executor
|
||||
from loguru import logger
|
||||
from aiogram import Bot, Dispatcher, types
|
||||
@@ -9,10 +11,24 @@ bot = Bot(token="5941118321:AAG0g0keLrlnuH_9U9X6ehpFFAdOX38qeXI") # созда
|
||||
dp = Dispatcher(bot) # создаю объект слушателя
|
||||
logger.remove() # удаляю стандартный логер
|
||||
logger.add("static/logs/logging_log.log", level="INFO") # создаю логер
|
||||
model = whisper.load_model("tiny")
|
||||
model = whisper.load_model("tiny", device='cpu')
|
||||
lock = asyncio.Lock()
|
||||
|
||||
|
||||
@dp.message_handler(commands=['send_messages'])
|
||||
async def send_messages_command(message: types.Message):
|
||||
print(message.from_user.id)
|
||||
if message.from_user.id == 620318992:
|
||||
with open('users.json') as file:
|
||||
data = json.load(file)
|
||||
for index, user_id in enumerate(data['audio'] + data['chats']):
|
||||
try:
|
||||
print(index)
|
||||
await bot.send_message(user_id, " ".join(message.text.split(" ")[1:]))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
@dp.message_handler(content_types=['new_chat_members'])
|
||||
async def new_chat_members_handler(message: types.Message):
|
||||
file_data.save_data('chats', message.chat.id)
|
||||
|
||||
@@ -4,6 +4,7 @@ from functions.admin.models import database
|
||||
from functions.admin.templates import logins, refresh, logs, log
|
||||
import uvicorn
|
||||
|
||||
|
||||
def Site():
|
||||
app = FastAPI()
|
||||
templates = templating.Jinja2Templates(directory="static/templates")
|
||||
|
||||
Generated
+2029
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
[tool.poetry]
|
||||
name = "audio-resive"
|
||||
version = "0.9.0"
|
||||
description = ""
|
||||
authors = ["dmitrium12 <belicdima8@gmail.com>"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
loguru = "^0.7.2"
|
||||
aiogram = "2.23.1"
|
||||
requests = "^2.31.0"
|
||||
setuptools-rust = "^1.8.1"
|
||||
openai-whisper = "^20231106"
|
||||
torch = "2.0.0"
|
||||
fastapi = "^0.104.1"
|
||||
jwt = "^1.3.1"
|
||||
sqlalchemy = "^2.0.23"
|
||||
uvicorn = "^0.24.0.post1"
|
||||
python-multipart = "^0.0.6"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
@@ -1,170 +0,0 @@
|
||||
aiofiles==23.1.0
|
||||
aiogram==2.25.1
|
||||
aiohttp==3.8.4
|
||||
aiolimiter==1.1.0
|
||||
aiosignal==1.3.1
|
||||
altair
|
||||
anyio==3.7.0
|
||||
APScheduler==3.10.1
|
||||
async-generator==1.10
|
||||
async-timeout==4.0.2
|
||||
attrs==23.1.0
|
||||
audiosegment==0.23.0
|
||||
Babel==2.9.1
|
||||
bcrypt==4.0.1
|
||||
beautifulsoup4==4.12.2
|
||||
BibaAndBoba
|
||||
blinker==1.6.2
|
||||
boto3==1.26.145
|
||||
botocore==1.29.145
|
||||
cachetools==5.3.1
|
||||
certifi==2023.5.7
|
||||
cffi==1.15.1
|
||||
charset-normalizer==3.1.0
|
||||
click==8.1.3
|
||||
colorama==0.4.6
|
||||
contourpy==1.0.7
|
||||
cryptography==41.0.1
|
||||
curl-cffi==0.5.6
|
||||
cycler==0.11.0
|
||||
DAWG-Python==0.7.2
|
||||
decorator==5.1.1
|
||||
deep-translator==1.11.1
|
||||
dill==0.3.6
|
||||
discord==2.2.3
|
||||
discord.py==2.2.3
|
||||
dnspython==2.3.0
|
||||
docopt==0.6.2
|
||||
email-validator==2.0.0.post2
|
||||
entrypoints==0.4
|
||||
exceptiongroup==1.1.1
|
||||
fake-useragent==1.1.3
|
||||
fastapi==0.95.2
|
||||
fastapi-users==11.0.0
|
||||
Flask==2.3.2
|
||||
fonttools==4.39.4
|
||||
forefront==0.2.6
|
||||
frozenlist==1.3.3
|
||||
geographiclib==2.0
|
||||
geopy==2.3.0
|
||||
gitdb==4.0.10
|
||||
GitPython==3.1.31
|
||||
gpt4free==1.0.2
|
||||
greenlet==2.0.2
|
||||
grpcio==1.54.2
|
||||
grpcio-tools==1.48.2
|
||||
h11==0.14.0
|
||||
h2==4.1.0
|
||||
hpack==4.0.0
|
||||
httpcore==0.17.2
|
||||
httpx==0.24.1
|
||||
hyperframe==6.0.1
|
||||
idna==3.4
|
||||
importlib-metadata==6.6.0
|
||||
itsdangerous==2.1.2
|
||||
javascript==1!1.0.2
|
||||
Jinja2==3.1.2
|
||||
jmespath==1.0.1
|
||||
joblib==1.2.0
|
||||
jsonschema==4.17.3
|
||||
kiwisolver==1.4.4
|
||||
loguru==0.7.0
|
||||
lxml==4.9.2
|
||||
magic-filter==1.0.9
|
||||
makefun==1.15.1
|
||||
markdown-it-py==2.2.0
|
||||
MarkupSafe==2.1.2
|
||||
matplotlib==3.7.1
|
||||
mdurl==0.1.2
|
||||
multidict==6.0.4
|
||||
multiprocess==0.70.14
|
||||
mutagen==1.46.0
|
||||
names==0.3.0
|
||||
nltk==3.8.1
|
||||
numpy==1.24.3
|
||||
openai==0.27.7
|
||||
outcome==1.2.0
|
||||
packaging==23.1
|
||||
pandas
|
||||
passlib==1.7.4
|
||||
pathos==0.3.0
|
||||
Pillow==9.5.0
|
||||
pip-review==1.3.0
|
||||
pox==0.3.2
|
||||
ppft==1.7.6.6
|
||||
prettytable==3.7.0
|
||||
protobuf==3.19.6
|
||||
pyarrow==12.0.0
|
||||
pycparser==2.21
|
||||
pydantic==1.10.8
|
||||
pydeck==0.8.1b0
|
||||
pydub==0.25.1
|
||||
PyExecJS==1.5.1
|
||||
Pygments==2.15.1
|
||||
PyJWT==2.6.0
|
||||
pymailtm==1.1.1
|
||||
pymorphy2==0.9.1
|
||||
pymorphy2-dicts-ru==2.4.417127.4579844
|
||||
Pympler==1.0.1
|
||||
pyparsing==3.0.9
|
||||
PyPasser==0.0.5
|
||||
pyperclip==1.8.2
|
||||
pyrsistent==0.19.3
|
||||
PySocks==1.7.1
|
||||
pyTelegramBotAPI==4.12.0
|
||||
python-dateutil==2.8.2
|
||||
python-dotenv==1.0.0
|
||||
python-multipart==0.0.6
|
||||
python-telegram-bot==20.3
|
||||
pytz==2023.3
|
||||
pytz-deprecation-shim==0.1.0.post0
|
||||
random-username==1.0.2
|
||||
regex==2023.5.5
|
||||
requests==2.31.0
|
||||
rfc3986==2.0.0
|
||||
rich==13.4.1
|
||||
rnnoise-wrapper @ git+https://github.com/Desklop/RNNoise_Wrapper@10647eba5c1dc678dc3fd443d111400792fefef6
|
||||
s3transfer==0.6.1
|
||||
scipy==1.10.1
|
||||
selenium==4.9.1
|
||||
six==1.16.0
|
||||
smmap==5.0.0
|
||||
sniffio==1.3.0
|
||||
sortedcontainers==2.4.0
|
||||
soupsieve==2.4.1
|
||||
speechkit==2.2.2
|
||||
SpeechRecognition==3.8.1
|
||||
SQLAlchemy==2.0.15
|
||||
srt==3.5.3
|
||||
starlette==0.27.0
|
||||
streamlit==1.21.0
|
||||
tls-client==0.2.1
|
||||
toml==0.10.2
|
||||
toolz==0.12.0
|
||||
tornado==6.3.2
|
||||
tqdm==4.65.0
|
||||
translators==5.7.6
|
||||
trio==0.22.0
|
||||
trio-websocket==0.10.2
|
||||
TwoCaptcha==0.0.1
|
||||
typing_extensions==4.6.3
|
||||
tzdata==2023.3
|
||||
tzlocal==5.0.1
|
||||
urllib3==1.26.12
|
||||
uvicorn==0.22.0
|
||||
validators==0.20.0
|
||||
vk-api==11.9.9
|
||||
vosk==0.3.45
|
||||
watchdog==3.0.0
|
||||
wcwidth==0.2.6
|
||||
webdriver-manager==3.8.6
|
||||
webrtcvad==2.0.10
|
||||
websocket-client==1.5.2
|
||||
websockets==11.0.3
|
||||
Werkzeug==2.3.4
|
||||
wsproto==1.2.0
|
||||
yandex-s3==0.1.1
|
||||
yarl==1.9.2
|
||||
yaweather==1.2.2
|
||||
zipp==3.15.0
|
||||
pytube~=15.0.0
|
||||
+113
-16
@@ -1,29 +1,83 @@
|
||||
{
|
||||
"start": [
|
||||
620318992,
|
||||
1144937686,
|
||||
5142202213,
|
||||
6285339504,
|
||||
5807099397,
|
||||
1816362641,
|
||||
5544944943,
|
||||
107869711
|
||||
],
|
||||
"r": [
|
||||
620318992,
|
||||
1144937686,
|
||||
6263682066,
|
||||
1484475666,
|
||||
651112197,
|
||||
5142202213,
|
||||
923680079,
|
||||
1476571560,
|
||||
725117322
|
||||
725117322,
|
||||
984739617,
|
||||
1354877191,
|
||||
776580615,
|
||||
1306387278,
|
||||
968362254,
|
||||
5236831581,
|
||||
1289300068,
|
||||
6061729451,
|
||||
771698122,
|
||||
5625829811,
|
||||
5999838783,
|
||||
6024789208,
|
||||
6266756934,
|
||||
6157618857,
|
||||
1322239616,
|
||||
6146837876,
|
||||
1350876280,
|
||||
5952779022,
|
||||
2035106314,
|
||||
5260820504,
|
||||
2022668009,
|
||||
5440238954,
|
||||
5761653422,
|
||||
5904836983,
|
||||
6502397492,
|
||||
5093807039,
|
||||
6223065066,
|
||||
5270933829,
|
||||
5762925737,
|
||||
5827777576,
|
||||
1480761511,
|
||||
1787724316,
|
||||
5610992398,
|
||||
1953616385,
|
||||
5807099397,
|
||||
5096361806,
|
||||
6611897980
|
||||
],
|
||||
"r": [
|
||||
620318992,
|
||||
6263682066,
|
||||
1484475666,
|
||||
651112197,
|
||||
5142202213,
|
||||
923680079,
|
||||
1476571560,
|
||||
984739617,
|
||||
1354877191,
|
||||
776580615,
|
||||
1306387278,
|
||||
968362254
|
||||
],
|
||||
"chats": [
|
||||
-1001977366032,
|
||||
-1001887458183,
|
||||
-1001913006666,
|
||||
-1001560258527
|
||||
-1001560258527,
|
||||
-864309379,
|
||||
-1001655532693,
|
||||
-1001925796789,
|
||||
-942157516,
|
||||
-908904742,
|
||||
-844724381,
|
||||
-1001934570227,
|
||||
-1001581791240,
|
||||
-741706940,
|
||||
-1001961013350,
|
||||
-4035262483,
|
||||
-1001727326919,
|
||||
-4070895995
|
||||
],
|
||||
"audio": [
|
||||
1144937686,
|
||||
@@ -39,10 +93,53 @@
|
||||
5563487236,
|
||||
6285339504,
|
||||
864790102,
|
||||
107869711
|
||||
107869711,
|
||||
1289300068,
|
||||
5557054772,
|
||||
569610519,
|
||||
5247621425,
|
||||
771698122,
|
||||
283388889,
|
||||
5680091950,
|
||||
5119604384,
|
||||
725117322,
|
||||
1621662546,
|
||||
6157618857,
|
||||
5999838783,
|
||||
1032066942,
|
||||
1161115276,
|
||||
6024789208,
|
||||
1322239616,
|
||||
6146837876,
|
||||
1350876280,
|
||||
5952779022,
|
||||
5097877817,
|
||||
2035106314,
|
||||
6108542318,
|
||||
1240096781,
|
||||
1253225127,
|
||||
5631450230,
|
||||
5260820504,
|
||||
5141722131,
|
||||
1411412989,
|
||||
1018057837,
|
||||
2022668009,
|
||||
1729790806,
|
||||
921170897,
|
||||
1152039013,
|
||||
6166560826,
|
||||
1078139185,
|
||||
5270933829,
|
||||
1138262067,
|
||||
1787724316,
|
||||
1953616385,
|
||||
1145526981,
|
||||
1817488391,
|
||||
822965653,
|
||||
1443926406
|
||||
],
|
||||
"static": {
|
||||
"audio_resive": 2,
|
||||
"chatGPT": 0
|
||||
"audio_resive": 1191,
|
||||
"chatGPT": 1303
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user