mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2026-01-04 21:45:33 +01:00
fixed mistakes from rebase :/
This commit is contained in:
@@ -147,18 +147,12 @@ class ChatGPT3TelegramBot:
|
||||
)
|
||||
return
|
||||
|
||||
logging.info(f'New transcribe request received from user {update.message.from_user.name}')
|
||||
filename_mp3 = f'{filename}.mp3'
|
||||
|
||||
user_id = update.message.from_user.id
|
||||
if user_id not in self.usage:
|
||||
self.usage[user_id] = UsageTracker(user_id)
|
||||
|
||||
chat_id = update.effective_chat.id
|
||||
await context.bot.send_chat_action(chat_id=chat_id, action=constants.ChatAction.TYPING)
|
||||
filename = update.message.voice.file_unique_id if update.message.voice else update.message.audio.file_unique_id
|
||||
filename_ogg = f'{filename}.ogg'
|
||||
filename_mp3 = f'{filename}.mp3'
|
||||
|
||||
try:
|
||||
if update.message.voice:
|
||||
media_file = await context.bot.get_file(update.message.voice.file_id)
|
||||
@@ -338,7 +332,7 @@ class ChatGPT3TelegramBot:
|
||||
application.add_handler(CommandHandler('image', self.image))
|
||||
application.add_handler(CommandHandler('start', self.help))
|
||||
application.add_handler(CommandHandler('stats', self.stats))
|
||||
application.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, self.transcribe))
|
||||
application.add_handler(MessageHandler(filters.VOICE | filters.AUDIO | filters.VIDEO, self.transcribe))
|
||||
application.add_handler(MessageHandler(filters.TEXT & (~filters.COMMAND), self.prompt))
|
||||
application.add_handler(InlineQueryHandler(self.inline_query, chat_types=[
|
||||
constants.ChatType.GROUP, constants.ChatType.SUPERGROUP
|
||||
|
||||
@@ -104,7 +104,7 @@ class UsageTracker:
|
||||
|
||||
# transcription usage functions:
|
||||
|
||||
def add_audio_seconds(self, seconds):
|
||||
def add_transcription_seconds(self, seconds):
|
||||
# TODO: implement
|
||||
pass
|
||||
|
||||
@@ -113,13 +113,13 @@ class UsageTracker:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def cost_tokens(seconds, minute_price=0.006):
|
||||
def cost_transcription(seconds, minute_price=0.006):
|
||||
# cost of audio seconds transcribed, amount in USD
|
||||
# current price Whisper: $0.002/1000 tokens
|
||||
second_price = minute_price/60
|
||||
return seconds * second_price
|
||||
|
||||
def get_audio_seconds_and_cost(self, date=date.today(), minute_price=0.006):
|
||||
def get_transcription_seconds_and_cost(self, date=date.today(), minute_price=0.006):
|
||||
# TODO: implement
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user