-
Notifications
You must be signed in to change notification settings - Fork 15
/
receive_call.py
27 lines (20 loc) · 878 Bytes
/
receive_call.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import asyncio
import pyrogram
from tgvoip import VoIPServerConfig
from tgvoip_pyrogram import VoIPFileStreamService, VoIPIncomingFileStreamCall,\
VoIPNativeIOService, VoIPIncomingNativeIOCall
VoIPServerConfig.set_bitrate_config(80000, 100000, 60000, 5000, 5000)
client = pyrogram.Client('session')
loop = asyncio.get_event_loop()
service = VoIPFileStreamService(client) # use VoIPNativeIOService for native I/O
@service.on_incoming_call
async def process_call(call: VoIPIncomingFileStreamCall): # use VoIPIncomingNativeIOCall for native I/O
await call.accept()
call.play('input.raw')
call.play_on_hold(['input.raw'])
call.set_output_file('output.raw')
# you can use `call.on_call_ended(lambda _: app.stop())` here instead
@call.on_call_ended
async def call_ended(call):
await client.stop()
loop.run_until_complete(client.run())