n3d1117 / chatgpt-telegram-bot

🤖 A Telegram bot that integrates with OpenAI's official ChatGPT APIs to provide answers, written in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No direct answer on voice message

Marcello87 opened this issue · comments

I first thought it was a error.
Would it be possible to answer (with chatgpt) directly after whisper has transcribe the audio message?

This would eliminate the manual step copying of the text after transcibe.

Screenshot ChatGPTBot

Hi @Marcello87, that's interesting. I originally intended it as a way to only transcribe audio messages, and not as a direct voice command to ChatGPT.

Should be as easy as replacing these lines:

# Send the transcript
await context.bot.send_message(
chat_id=chat_id,
reply_to_message_id=update.message.message_id,
text=transcript,
parse_mode=constants.ParseMode.MARKDOWN
)

With:

response = self.openai.get_chat_response(chat_id=chat_id, query=transcript)
await context.bot.send_message(
    chat_id=chat_id,
    reply_to_message_id=update.message.message_id,
    text=response,
    parse_mode=constants.ParseMode.MARKDOWN
)

But I'm not sure how to allow both modes. Will keep this issue open for now, in case someone wants to help

Tested, works great for me, many thanks for the quick response.

I think it's difficult to use both modes at the same time. Maybe we can set a parameter like VOICE_TO_CHAT and let users select their prefer mode.

Thanks @Marcello87 @slippersheepig
Added VOICE_REPLY_WITH_TRANSCRIPT_ONLY env parameter which defaults to true

When I set VOICE_REPLY_WITH_TRANSCRIPT_ONLY to false, can I let the bot transcribe my voice and output it first, then reply it? It's more user-friendly.