Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of long voice messages #28

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/bot/batched_input_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ async def handle_voice(self, message: types.Message, user: User, message_process
speech_text = await get_audio_speech_to_text(mp3_filename)
speech_text = f'speech2text:\n{speech_text}'

response = await message.reply(speech_text)
await message_processor.add_text_as_context(speech_text, response.message_id)
# split speech_text to chunks of 4080 symbols
chunk_size = 4080
speech_text_chunks = [speech_text[i:i + chunk_size] for i in range(0, len(speech_text), chunk_size)]
for chunk in speech_text_chunks:
response = await message.reply(chunk)
await message_processor.add_text_as_context(chunk, response.message_id)

async def handle_message(self, message: types.Message, user: User, message_processor: MessageProcessor):
"""
Expand Down