Module: ChatgptAssistant::Bots::Discord::VoiceActions

Included in:
DiscordBot
Defined in:
lib/chatgpt_assistant/bots/discord/voice_actions.rb

Instance Method Summary collapse

Instance Method Details

#ask_to_speak_actionObject



7
8
9
10
11
12
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 7

def ask_to_speak_action
  Message.create(chat_id: chat.id, content: message, role: "user", discord_message_id: evnt.message.id)
  response = chatter.chat(message, chat.id, error_messages[:something_went_wrong])
  audio_path = synthesis.synthesize_text(response)
  speak_answer_action(audio_path, response)
end

#disconnect_actionObject



26
27
28
29
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 26

def disconnect_action
  bot.voice_destroy(evnt.user.voice_channel)
  "Disconnected from voice channel"
end

#discord_voice_bot_connectObject



21
22
23
24
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 21

def discord_voice_bot_connect
  bot.voice_connect(evnt.user.voice_channel) if discord_voice_bot_disconnected?
  discord_voice_bot_connected? ? "Connected to voice channel" : "Error connecting to voice channel"
end

#speak_answer_action(audio_path, response) ⇒ Object



14
15
16
17
18
19
# File 'lib/chatgpt_assistant/bots/discord/voice_actions.rb', line 14

def speak_answer_action(audio_path, response)
  send_message response
  evnt.voice.play_file(audio_path)
  delete_file audio_path
  "OK"
end