Closed kvmukhin closed 3 years ago
Can u show ur code? Did u try run recorder example?
I`m use example - https://github.com/MarshalX/tgcalls/blob/main/examples/playout.py (with small edits) and my sound file mp3 (convert ffmpeg -i input.mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw) In telegram music play ok
What is the file size? Is the duration consistent (after converting) with reality?
Yes. Size and duration simile real.
Can you reproduce it with 100% probability?
yes, i tried different input files always 'output' file after convert have size and not null duration, but listen only silence. may be example have error?
the example implementation is correct. can you send a log file?
My implementation:
import asyncio
import pytgcalls
import pyrogram
API_HASH = None
API_ID = None
CHAT_ID = ''
INPUT_FILENAME = 'input1.raw'
OUTPUT_FILENAME = 'output.raw'
async def end_track(gc: pytgcalls.GroupCall, filename: str):
print(f'Track ended {filename}')
gc.input_filename = 'input.raw'
print(f'Track load {gc.input_filename}')
async def main(client):
await client.start()
while not client.is_connected:
await asyncio.sleep(1)
group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False)
group_call.on_playout_ended(end_track)
await group_call.start(CHAT_ID)
await pyrogram.idle()
if __name__ == '__main__':
pyro_client = pyrogram.Client(
os.environ.get('SESSION_NAME', 'pytgcalls'),
api_hash=os.environ.get('API_HASH', API_HASH),
api_id=os.environ.get('API_ID', API_ID)
)
loop = asyncio.get_event_loop()
loop.run_until_complete(main(pyro_client))```
My implementation:
import asyncio import pytgcalls import pyrogram API_HASH = None API_ID = None CHAT_ID = '' INPUT_FILENAME = 'input1.raw' OUTPUT_FILENAME = 'output.raw' async def end_track(gc: pytgcalls.GroupCall, filename: str): print(f'Track ended {filename}') gc.input_filename = 'input.raw' print(f'Track load {gc.input_filename}') async def main(client): await client.start() while not client.is_connected: await asyncio.sleep(1) group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False) group_call.on_playout_ended(end_track) await group_call.start(CHAT_ID) await pyrogram.idle() if __name__ == '__main__': pyro_client = pyrogram.Client( os.environ.get('SESSION_NAME', 'pytgcalls'), api_hash=os.environ.get('API_HASH', API_HASH), api_id=os.environ.get('API_ID', API_ID) ) loop = asyncio.get_event_loop() loop.run_until_complete(main(pyro_client))```
U don’t pass output filename to group call constructor. If u want to record u should pass it)
My implementation:
import asyncio import pytgcalls import pyrogram API_HASH = None API_ID = None CHAT_ID = '' INPUT_FILENAME = 'input1.raw' OUTPUT_FILENAME = 'output.raw' async def end_track(gc: pytgcalls.GroupCall, filename: str): print(f'Track ended {filename}') gc.input_filename = 'input.raw' print(f'Track load {gc.input_filename}') async def main(client): await client.start() while not client.is_connected: await asyncio.sleep(1) group_call = pytgcalls.GroupCall(client, INPUT_FILENAME, play_on_repeat=False) group_call.on_playout_ended(end_track) await group_call.start(CHAT_ID) await pyrogram.idle() if __name__ == '__main__': pyro_client = pyrogram.Client( os.environ.get('SESSION_NAME', 'pytgcalls'), api_hash=os.environ.get('API_HASH', API_HASH), api_id=os.environ.get('API_ID', API_ID) ) loop = asyncio.get_event_loop() loop.run_until_complete(main(pyro_client))```
U don’t pass output filename to group call constructor. If u want to record u should pass it)
Oh) i deleted 'OUTPUT_FILENAME' because file grow. I can send early get 'output' file
Are you sure that the other members of the voice chat said something? To get it on the record. the bot does not record itself ofc)
It explains everything :) Thx)
Output file has a not null size, but after conversion, when listening to silence Convert cmd: ffmpeg -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -i output.raw clear_output.mp3