Skip to content

Commit

Permalink
Merge pull request #28 from ijwfly/bugfix/very-long-voice-message
Browse files Browse the repository at this point in the history
Fix handling of long voice messages
  • Loading branch information
ijwfly committed Apr 9, 2024
2 parents 9b7c408 + 9729b58 commit aa1a7da
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit aa1a7da

Please sign in to comment.