First commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.env
|
||||
0
data/audio/DUMMY
Normal file
0
data/audio/DUMMY
Normal file
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
telemovris:
|
||||
build: telemovris
|
||||
image: telemovris:latest
|
||||
container_name: telemovris
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/data
|
||||
environment:
|
||||
- API_ID=${API_ID}
|
||||
- API_HASH=${API_HASH}
|
||||
12
telemovris/Dockerfile
Normal file
12
telemovris/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM python:3.9
|
||||
|
||||
RUN apt update
|
||||
RUN apt install ffmpeg make cmake gcc g++ python3-dev gcc g++ openssl libssl-dev libopus0 libopus-dev -y
|
||||
RUN mkdir /app
|
||||
ADD requirements.txt /app
|
||||
ADD *.py /app/
|
||||
RUN pip install -r /app/requirements.txt
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
CMD [ "python", "/app/telemovris.py" ]
|
||||
6
telemovris/requirements.txt
Normal file
6
telemovris/requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Pyrogram==1.4.0
|
||||
TgCrypto==1.2.5
|
||||
pytgvoip==0.0.7.1
|
||||
pytgvoip-pyrogram==0.0.11
|
||||
TTS==0.15.6
|
||||
numpy==1.22.0
|
||||
47
telemovris/telemovris.py
Normal file
47
telemovris/telemovris.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import asyncio
|
||||
import os
|
||||
from TTS.api import TTS
|
||||
import random
|
||||
import string
|
||||
|
||||
from tgvoip import VoIPServerConfig
|
||||
from tgvoip_pyrogram import VoIPFileStreamService, VoIPNativeIOService
|
||||
import pyrogram
|
||||
|
||||
def get_random_string(length):
|
||||
# choose from all lowercase letter
|
||||
letters = string.ascii_lowercase
|
||||
result_str = ''.join(random.choice(letters) for i in range(length))
|
||||
print("Random string of length", length, "is:", result_str)
|
||||
|
||||
tts = TTS("tts_models/es/mai/tacotron2-DDC")
|
||||
|
||||
client = pyrogram.Client(os.environ.get('SESSION_NAME', '/data/telemovris'),
|
||||
api_hash=os.environ.get('API_HASH'),
|
||||
api_id=os.environ.get('API_ID'),
|
||||
)
|
||||
|
||||
VoIPServerConfig.set_bitrate_config(80000, 100000, 60000, 5000, 5000)
|
||||
loop = asyncio.get_event_loop()
|
||||
voip_service = VoIPFileStreamService(client, receive_calls=False)
|
||||
|
||||
@client.on_message(pyrogram.filters.command('callme'))
|
||||
async def callme(cl, message: pyrogram.types.Message):
|
||||
message = message.text.split('/callme ')[1]
|
||||
audio_name = get_random_string(10)
|
||||
tts.tts_to_file(text=message, file_path=f"/data/audio/{audio_name}.wav")
|
||||
os.system(f"ffmpeg -i /data/audio/{audio_name}.wav -f s16le -ac 1 -ar 48000 -acodec pcm_s16le /data/audio/{audio_name}.raw")
|
||||
|
||||
await client.send_message(message.from_user.id, "test jejeje")
|
||||
call = await voip_service.start_call(message.from_user.id)
|
||||
call.play(f"/data/audio/{audio_name}.raw")
|
||||
call.set_output_file(f'/data/audio/{audio_name}_output.raw')
|
||||
|
||||
async def main():
|
||||
await client.start()
|
||||
print(await client.export_session_string())
|
||||
await pyrogram.idle()
|
||||
|
||||
loop.run_until_complete(main())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user